anchor.diff:        (%reschedule)
         t)))
   
  +(defun acquire-spin-mutex (mutex wait-p)
  +  (let ((self (current-thread))
  +        (istate (sys.int::%interrupt-state)))
  +    (sys.int::%cli)
  +    ;; Fast path - try to lock.
  +    (when (sys.int::%cas-struct-slot mutex 5 nil self)
  +      ;; We got it.
  +      (setf (mutex-%lock mutex) istate)
  +      (return-from acquire-spin-mutex t))
  +    ;; Idiot check.
  +    (assert (not (mutex-held-p mutex)) (mutex)
  +            "Recursive locking detected.")
  +    (cond (wait-p
  +           ;; Spin path.
  +           (do ()
  +               ((sys.int::%cas-struct-slot mutex 5 nil self))
  +             (sys.int::cpu-relax))
  +           (setf (mutex-%lock mutex) istate)
  +           t)
  +          (t ;; Trylock path.
  +           (when istate
  +             (sys.int::%sti))))))
  +
   (defun mutex-held-p (mutex)
     "Return true if this thread holds MUTEX."
     (eql (mutex-owner mutex) (current-thread)))
   
   (defun release-mutex (mutex)
     (assert (mutex-held-p mutex))
  +  (ecase (mutex-kind mutex)
  +    (:block (release-block-mutex mutex))
  +    (:spin (release-spin-mutex mutex)))
  +  (values))
  +
  +(defun release-block-mutex (mutex)
     (with-wait-queue-lock (mutex)
       ;; Look for a thread to wake.
       (let ((thread (pop-wait-queue mutex)))
  
positive.code:              (:constructor make-condition-variable (&optional name))
               (:area :wired)))
  
  (defun condition-wait (condition-variable lock)
    (assert (mutex-held-p mutex))
    (assert (sys.int::%interrupt-state))
    (let ((self (current-thread)))
      (with-footholds-inhibited
          (sys.int::%cli)
        (lock-wait-queue condition-variable)
        ;; Attach to the list.
        (push-wait-queue self condition-variable)
        ;; Drop the mutex.
  
negative.code:       (sys.int::%cli)
        (lock-wait-queue mutex)
        ;; Try to acquire again, release may have been running.
        (when (sys.int::%cas-struct-slot mutex 5 nil self)
          ;; We got it.
          (sys.int::%sti)
          (unlock-wait-queue mutex)
          (return-from acquire-block-mutex t))
        ;; No good, have to sleep. Release will directly transfer ownership
        ;; to this thread.
        (push-wait-queue self mutex)
  