- "Acquire MUTEX, setting it to NEW-VALUE or some suitable default
-value if NIL. If WAIT-P is non-NIL and the mutex is in use, sleep
-until it is available."
- (declare (type mutex mutex) (optimize (speed 3)))
- (/show0 "Entering GET-MUTEX")
- (unless new-value
- (setq new-value *current-thread*))
- #!-sb-thread
- (let ((old-value (mutex-value mutex)))
- (when (and old-value wait-p)
- (error "In unithread mode, mutex ~S was requested with WAIT-P ~S and ~
- new-value ~S, but has already been acquired (with value ~S)."
- mutex wait-p new-value old-value))
- (setf (mutex-value mutex) new-value)
- t)
+ "Acquire MUTEX for NEW-OWNER, which must be a thread or NIL. If
+NEW-OWNER is NIL, it defaults to the current thread. If WAITP is
+non-NIL and the mutex is in use, sleep until it is available.
+
+Note: using GET-MUTEX to assign a MUTEX to another thread then the
+current one is not recommended, and liable to be deprecated.
+
+GET-MUTEX is not interrupt safe. The correct way to call it is:
+
+ (WITHOUT-INTERRUPTS
+ ...
+ (ALLOW-WITH-INTERRUPTS (GET-MUTEX ...))
+ ...)
+
+WITHOUT-INTERRUPTS is necessary to avoid an interrupt unwinding the
+call while the mutex is in an inconsistent state while
+ALLOW-WITH-INTERRUPTS allows the call to be interrupted from sleep.
+
+It is recommended that you use WITH-MUTEX instead of calling GET-MUTEX
+directly."
+ (declare (type mutex mutex) (optimize (speed 3))
+ #!-sb-thread (ignore waitp))
+ (unless new-owner
+ (setq new-owner *current-thread*))
+ (when (eql new-owner (mutex-%owner mutex))
+ (error "Recursive lock attempt ~S." mutex))