X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fthread.lisp;h=a780b16887ad4e72fd9c14f2465f7946233be14d;hb=d94c1b4a8c534bde146823f56558faf37cd4c4d7;hp=6e427886bb35acf9e265b3acf24e4122c2c0ab6d;hpb=4255b37e50876702d2563f3418a44a3f5bf8a2e8;p=sbcl.git diff --git a/src/code/thread.lisp b/src/code/thread.lisp index 6e42788..a780b16 100644 --- a/src/code/thread.lisp +++ b/src/code/thread.lisp @@ -107,15 +107,22 @@ stale value, use MUTEX-OWNER instead." 'progn 'with-local-interrupts))) `(let* ((,thread *current-thread*) - (,prev (thread-waiting-for ,thread))) + (,prev (progn + (barrier (:read)) + (thread-waiting-for ,thread)))) (flet ((exec () ,@body)) (if ,prev (,without (unwind-protect (progn (setf (thread-waiting-for ,thread) nil) + (barrier (:write)) (,with (exec))) - (setf (thread-waiting-for ,thread) ,prev))) + ;; If we were waiting on a waitqueue, this becomes a bogus + ;; wakeup. + (when (mutex-p ,prev) + (setf (thread-waiting-for ,thread) ,prev) + (barrier (:write))))) (exec))))))) (sb!xc:defmacro with-mutex ((mutex &key (value '*current-thread*) (wait-p t))