The mutex extensions provide mutual exclusion primitives for synchronising concurrent LispBM processes. These extensions may or may not be present depending on the platform and configuration of LispBM.
mutex-create creates a mutex for mutual exclusion
between concurrent LispBM processes. The form of a
mutex-create expression is (mutex-create).
Returns a mutex object. Internally the mutex is represented as a dotted
pair used as a queue of waiting process IDs, and can be accidentally
destroyed by standard list operations.
| Example | Result |
|
|
mutex-lock acquires a mutex. The form of a
mutex-lock expression is (mutex-lock mutex).
If the mutex is unlocked, the calling process acquires it and returns
t. If the mutex is already held by another process, the
calling process is blocked until the mutex becomes available. A process
must not attempt to lock a mutex it already holds, as this will cause a
deadlock. It is recommended to use mutex-lock and
mutex-unlock together in a wrapper that guarantees
unlocking, for example:
| Example | Result |
|
|
|
|
|
|
mutex-unlock releases a mutex. The form of a
mutex-unlock expression is
(mutex-unlock mutex). Must be called by the same process
that holds the lock. Returns t on success and unblocks the
next waiting process if any. Returns an error if the mutex is not
currently locked.
| Example | Result |
|
|
|
|
|
|
This document was generated by LispBM version 0.38.0