Scieneer Common Lisp 1.3.9 online documentation

thread:with-exclusive-execution &body body[Macro]

Execute the body while being the only thread executing lisp code, or more precisely being the only thread holding the lisp heap lock. Exclusive contexts may be nested.

Interrupts must be enabled on entry to the exclusive context, unless entering a nested exclusive context, and interrupts are disabled within the exclusive context. If threads attempted to gain exclusive access to the heap with interrupts disabled then competing threads would deadlock. These restrictions are enforced and an error is generated if violated to avoid a deadlock.

The environment in which the body executes is susceptible to deadlocks. A deadlock would occur if an attempt were made to acquire a lock held by another thread blocked from executing lisp code and thus unable to release the lock. The system enforces restrictions on the context in which locks may be held in order to catch such deadlocks, and only locks that are held with interrupts disabled may be held within an exclusive execution context. Since only a subset of the standard lisp functions may be safe for use in this context it is not recommended for use by user code.