master: Use a barrier instead of CAS in mutex-owner
snuglas via Sbcl-commits <[email protected]> Thu, 30 Apr 2026 17:47:08 +0000
| Newsgroups | gmane.lisp.steel-bank.cvs |
|---|---|
| Message-ID | <[email protected]> |
The branch "master" has been updated in SBCL:
via 44c6928308e64daff70f67863c8d232e5e21bb85 (commit)
from 4acf4acdbdabc66630be96f3a88d9c339a5f4ec4 (commit)
- Log -----------------------------------------------------------------
commit 44c6928308e64daff70f67863c8d232e5e21bb85
Author: Douglas Katzman <[email protected]>
Date: Thu Apr 30 12:17:49 2026 -0400
Use a barrier instead of CAS in mutex-owner
Rev 5234b3ca in 20009 added a CAS because BARRIER did not exist.
BARRIER was invented later, rev 65b5ab7e in 2010.
And remove inline which has no reason for being
---
src/code/thread.lisp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/code/thread.lisp b/src/code/thread.lisp
index a80b669ce..6581c21ab 100644
--- a/src/code/thread.lisp
+++ b/src/code/thread.lisp
@@ -57,7 +57,6 @@ stale value, use MUTEX-OWNER instead."
;; sufficient.
(= (mutex-%owner mutex) (current-vmthread-id)))
-(declaim (inline mutex-owner))
(defun mutex-owner (mutex)
"Current owner of the mutex, NIL if the mutex is free. Naturally,
this is racy by design (another thread may acquire the mutex after
@@ -65,7 +64,8 @@ this function returns), it is intended for informative purposes. For
testing whether the current thread is holding a mutex see
HOLDING-MUTEX-P."
;; Make sure to get the current value.
- (let ((vmthread (sb-ext:compare-and-swap (mutex-%owner mutex) 0 0)))
+ (barrier (:read))
+ (let ((vmthread (mutex-%owner mutex)))
(cond ((= vmthread (current-vmthread-id)) *current-thread*)
((= vmthread 0) nil)
(t (mutex-owner-lookup vmthread)))))
-----------------------------------------------------------------------
hooks/post-receive
--
SBCL