5.2.5 Locks
The Multitasking Facility signals an error whenever a process attempts to acquire a lock while scheduling is inhibited or while interrupts are deferred. To prevent such potential deadlock errors, processes should not acquire locks while scheduling is either explicitly inhibited, by a call to the macrowith-scheduling-inhibited
, or implicitly inhibited. The following guidelines should help you avoid deadlocks:
process-wait
orprocess-allow-schedule
while scheduling is inhibited. Since callingprocess-lock
might callprocess-wait
, do not use the locking functions while scheduling is inhibited.setf
method.process-wait
function.disksave
.with-io-unlocked
around the method body.;;; Incorrect way to make sure windows do not move around between ;;; locating the window and drawing on it. (with-scheduling-inhibited (let ((window (find-topmost-window))) (draw-on-window window)))To prevent processes from waiting forever for a lock, use the;;; Correct way; the code inside WITH-SCHEDULING-INHIBITED will ;;; always be able to acquire the lock. (with-window-system-lock (with-scheduling-inhibited (let ((window (find-topmost-window))) (draw-on-window window))))
:action
keyword argument towith-process-lock
or the action argument toprocess-lock
to specify the action a process should take if a requested lock is already held by another process.
Generated with Harlequin WebMaker