anchor.diff:                      ;; Fall back on idle.
                       (local-cpu-idle-thread))))))))
   
  +(defun update-run-queue ()
  +  "Return the current thread to the run queue, if required and pick a new thread to run."
  +  (ensure-global-thread-lock-held)
  +  (let ((current (current-thread)))
  +    (ensure (not (eql (thread-state current) :active))
  +            "Current thread " current " has wrong state " (thread-state current))
  +    (let ((next (%update-run-queue)))
  +      (ensure (eql (thread-state next) :runnable) "Switching to thread " next " with bad state " (thread-state next))
  +      (setf (thread-state next) :active)
  +      (when (<= (car sys.int::*exception-stack*)
  +                (thread-stack-pointer next)
  +                (1- (+ (car sys.int::*exception-stack*)
  +                       (cdr sys.int::*exception-stack*))))
  +        (panic "Other thread " next " stopped on exception stack!!!"))
  +      next)))
  +
   ;;; Thread switching.
   
   (defun thread-yield ()
  
positive.code:   ;; Interrupts must be off and the global thread lock must be held.
    ;; Releases the thread lock and reenables interrupts.
    (ensure-global-thread-lock-held)
    (let ((current (current-thread))
          (next (%update-run-queue)))
      (when (eql next current)
        ;; Staying on the same thread, unlock and return.
        (release-global-thread-lock)
        (%%return-to-same-thread sp fp)
        (panic "unreachable"))
      (when (<= (car sys.int::*exception-stack*)
                (thread-stack-pointer next)
                (1- (+ (car sys.int::*exception-stack*)
                       (cdr sys.int::*exception-stack*))))
        (panic "Other thread " next " stopped on exception stack!!!"))
      (ensure (eql (thread-state next) :runnable) "Switching to thread " next " with bad state " (thread-state next))
      (setf (thread-state next) :active)
      (%%switch-to-thread-via-wired-stack current sp fp next)))
  
  (defun %reschedule-via-interrupt (interrupt-frame)
    ;; Switch to the next thread saving the full state.
    ;; Interrupts must be off and the global thread lock must be held.
    ;; Releases the thread lock and reenables interrupts.
    (ensure-global-thread-lock-held)
    (let ((current (current-thread))
          (next (%update-run-queue)))
      (when (not (eql next current))
        (ensure (eql (thread-state next) :runnable) "Switching to thread " next " with bad state " (thread-state next)))
      (setf (thread-state next) :active)
      (%%switch-to-thread-via-interrupt current interrupt-frame next)))
  
  (defun maybe-preempt-via-interrupt (interrupt-frame)
  
negative.code: (defun idle-thread ()
    (%disable-interrupts)
    (decrement-n-running-cpus)
    (let ((self (current-thread)))
      (loop
         ;; Must be running on the right CPU.
         (ensure (eql self (local-cpu-idle-thread)))
         ;; Make sure the preemption timer has been properly switched off when
         ;; the system idles. Not needed to be correct, but reduces activity
         ;; when idle.
         (ensure (not (preemption-timer-remaining)))
         ;; Look for a thread to switch to.
         (acquire-global-thread-lock)
         (setf (thread-state self) :runnable)
         (let ((next (update-run-queue)))
           (cond ((not (eql next self))
                  (increment-n-running-cpus)
                  ;; Switch to thread.
                  (%run-on-wired-stack-without-interrupts (sp fp next self)
                    (%%switch-to-thread-via-wired-stack self sp fp next))
                  (%disable-interrupts)
                  (decrement-n-running-cpus))
                 (t ;; Wait for an interrupt.
                  (release-global-thread-lock)
                  (%wait-for-interrupt)
                  (%disable-interrupts)))))))
  
  (defun increment-n-running-cpus ()
    (let ((prev (sys.int::%atomic-fixnum-add-symbol '*n-running-cpus* 1)))
  