master: Use linguistically correct terminology

snuglas via Sbcl-commits <[email protected]> Fri, 01 May 2026 02:32:11 +0000
Newsgroups gmane.lisp.steel-bank.cvs
Message-ID <[email protected]>
The branch "master" has been updated in SBCL:
       via  54825aa446a17b1d66aba2907495ab4efa6dd2e2 (commit)
      from  373080b6a4e13da702b983426a1ec76e92cecc54 (commit)

- Log -----------------------------------------------------------------
commit 54825aa446a17b1d66aba2907495ab4efa6dd2e2
Author: Douglas Katzman <[email protected]>
Date:   Thu Apr 30 22:31:14 2026 -0400

    Use linguistically correct terminology
    
    Google says: "Contested" implies an active challenge (like sports),
    also used abstractly in nonphysical situations like politics,
    whereas "contended" describes a state of resource competition.
    It cites these sources as authoritative examples of "contended":
    * Intel Architectures Software Developer’s Manual refers to
      Lock Contention and Contended Locks, not "contested locks"
    * Computer Architecture: A Quantitative Approach (Hennessy & Patterson)
      refers to "uncontended acquisition", not "uncontested acquisition"
---
 src/assembly/x86-64/tramps.lisp |  4 ++--
 src/code/target-thread.lisp     | 14 +++++++-------
 src/code/thread-structs.lisp    |  2 +-
 src/code/thread.lisp            |  4 ++--
 src/compiler/x86-64/tls.lisp    |  6 +++---
 src/runtime/sprof.c             | 12 ++++++------
 src/runtime/thread.c            |  2 +-
 tests/futex-wait.test.sh        | 12 ++++++------
 8 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/assembly/x86-64/tramps.lisp b/src/assembly/x86-64/tramps.lisp
index d344fba69..9703ec130 100644
--- a/src/assembly/x86-64/tramps.lisp
+++ b/src/assembly/x86-64/tramps.lisp
@@ -309,8 +309,8 @@
   (inst mov rax-tn (thread-tls-ea (load-time-tls-offset '*current-mutex*)))
   (inst mov :qword (mutex-slot rax-tn %owner) 0)
   (inst dec :lock :byte (mutex-slot rax-tn state))
-  (inst jmp :z uncontested) ; if ZF then previous value was 1, no waiters
+  (inst jmp :z uncontended) ; if ZF then previous value was 1, no waiters
   (inst call (make-fixup 'mutex-wake-waiter :assembly-routine))
-  uncontested
+  uncontended
   (inst pop rax-tn))
 ) ; end PROGN
diff --git a/src/code/target-thread.lisp b/src/code/target-thread.lisp
index 51e253633..f3a4d322a 100644
--- a/src/code/target-thread.lisp
+++ b/src/code/target-thread.lisp
@@ -39,7 +39,7 @@ COMPARE-AND-SWAP, and must initially hold NIL.
 WITH-CAS-LOCK is suitable mostly when the critical section needing protection
 is very small, and cost of allocating a separate lock object would be
 prohibitive. While it is the most lightweight locking constructed offered by
-SBCL, it is also the least scalable if the section is heavily contested or
+SBCL, it is also the least scalable if the section is heavily contended or
 long.
 
 WITH-CAS-LOCK can be entered recursively."
@@ -266,7 +266,7 @@ a simple-string (not necessarily unique) or NIL."
   (let ((name (mutex-name mutex)))
     (print-unreadable-object (mutex stream :type t :identity (not name))
       #+sb-futex
-      (format stream "~@[~S ~]~[free~;taken~;contested~:;err~] owner=~X"
+      (format stream "~@[~S ~]~[free~;taken~;contended~:;err~] owner=~X"
               name (mutex-state mutex) (vmthread-name (mutex-%owner mutex)))
       #-sb-futex
       (let ((owner (mutex-owner mutex))
@@ -782,10 +782,10 @@ returns NIL each time."
           (nlx-protect
            (if (not stop-sec)
                (loop                    ; untimed
-                     ;; Mark it as contested, and sleep, unless it is now in state 0.
+                     ;; Mark it as contended, and sleep, unless it is now in state 0.
                      (when (or (eql c 2) (/= 0 (sb-ext:cas val 1 2)))
                        (futex-wait (mutex-state-address mutex) 2 -1 0))
-                     ;; Try to get it, still marking it as contested.
+                     ;; Try to get it, still marking it as contended.
                      (when (= 0 (setq c (sb-ext:cas val 0 2))) (return))) ; win
                (loop             ; same as above but check for timeout
                      (when (or (eql c 2) (/= 0 (sb-ext:cas val 1 2)))
@@ -865,11 +865,11 @@ returns NIL each time."
            (c (sb-ext:cas val 0 1))) ; available -> taken
       (unless (= c 0) ; Got it right off the bat?
         (loop
-          ;; Mark it as contested, and sleep, unless it is now in state 0.
+          ;; Mark it as contended, and sleep, unless it is now in state 0.
           (when (or (eql c 2) (/= 0 (sb-ext:cas val 1 2)))
             (with-pinned-objects (mutex)
               (fast-futex-wait (mutex-state-address mutex) 2 -1 0)))
-          ;; Try to get it, still marking it as contested.
+          ;; Try to get it, still marking it as contended.
           (when (= 0 (setq c (sb-ext:cas val 0 2))) (return)))))) ; win
 
   (defun wait-for-mutex-algorithm-2 (mutex)
@@ -941,7 +941,7 @@ returns NIL each time."
 the mutex is not immediately available, sleep until it is available.
 
 If TIMEOUT is given, it specifies a relative timeout, in seconds, on how long
-GRAB-MUTEX should try to acquire the lock in the contested case.
+GRAB-MUTEX should try to acquire the lock in the contended case.
 
 If GRAB-MUTEX returns T, the lock acquisition was successful. In case of WAITP
 being NIL, or an expired TIMEOUT, GRAB-MUTEX may also return NIL which denotes
diff --git a/src/code/thread-structs.lisp b/src/code/thread-structs.lisp
index 0ab169d80..5f45e08f0 100644
--- a/src/code/thread-structs.lisp
+++ b/src/code/thread-structs.lisp
@@ -63,7 +63,7 @@
   (name nil :type (or null string))
   ;; For WITH-CAS-LOCK: because CONDITION-WAIT must be able to call
   ;; %WAITQUEUE-WAKEUP without re-aquiring the mutex, we need a separate
-  ;; lock. In most cases this should be uncontested thanks to the mutex --
+  ;; lock. In most cases this should be uncontended thanks to the mutex --
   ;; the only case where that might not be true is when CONDITION-WAIT
   ;; unwinds and %WAITQUEUE-DROP is called.
   . #+sb-futex nil
diff --git a/src/code/thread.lisp b/src/code/thread.lisp
index 6581c21ab..81196969f 100644
--- a/src/code/thread.lisp
+++ b/src/code/thread.lisp
@@ -188,7 +188,7 @@ HOLDING-MUTEX-P."
 and the MUTEX is not immediately available, sleep until it is available.
 
 If TIMEOUT is given, it specifies a relative timeout, in seconds, on how long
-the system should try to acquire the lock in the contested case.
+the system should try to acquire the lock in the contended case.
 
 If the mutex isn't acquired successfully due to either WAIT-P or TIMEOUT, the
 body is not executed, and WITH-MUTEX returns NIL.
@@ -249,7 +249,7 @@ If WAIT-P is true (the default), and the MUTEX is not immediately available or
 held by the current thread, sleep until it is available.
 
 If TIMEOUT is given, it specifies a relative timeout, in seconds, on how long
-the system should try to acquire the lock in the contested case.
+the system should try to acquire the lock in the contended case.
 
 If the mutex isn't acquired successfully due to either WAIT-P or TIMEOUT, the
 body is not executed, and WITH-RECURSIVE-LOCK returns NIL.
diff --git a/src/compiler/x86-64/tls.lisp b/src/compiler/x86-64/tls.lisp
index 836f151f2..a19717654 100644
--- a/src/compiler/x86-64/tls.lisp
+++ b/src/compiler/x86-64/tls.lisp
@@ -516,13 +516,13 @@
              (tls-cell (thread-tls-ea tls-index)))
         #+ultrafutex
         (when (eq symbol '*current-mutex*)
-          (let ((uncontested (gen-label)))
+          (let ((uncontended (gen-label)))
             (inst mov temp tls-cell) ; load the current value
             (inst mov :qword (mutex-slot temp %owner) 0)
             (inst dec :lock :byte (mutex-slot temp state))
-            (inst jmp :z uncontested) ; if ZF then previous value was 1, no waiters
+            (inst jmp :z uncontended) ; if ZF then previous value was 1, no waiters
             (invoke-asm-routine 'call 'mutex-wake-waiter vop)
-            (emit-label uncontested)))
+            (emit-label uncontended)))
 
         (inst sub bsp (* binding-size n-word-bytes))
 
diff --git a/src/runtime/sprof.c b/src/runtime/sprof.c
index 8fdf85fb1..328ad7b21 100644
--- a/src/runtime/sprof.c
+++ b/src/runtime/sprof.c
@@ -451,7 +451,7 @@ static int gather_trace_from_frame(struct thread* thread, uword_t* fp,
 
 #define LOCKED_BY_SELF  1
 #define LOCKED_BY_OTHER 2
-#define LOCK_CONTESTED  (LOCKED_BY_SELF|LOCKED_BY_OTHER)
+#define LOCK_CONTENDED  (LOCKED_BY_SELF|LOCKED_BY_OTHER)
 
 static void* initialize_sprof_data(struct thread* thread)
 {
@@ -481,14 +481,14 @@ static struct sprof_data* enlarge_buffer(struct sprof_data* current,
 #define SPROF_LOCK(th) thread_extra_data(th)->sprof_lock
 
 #ifdef LISP_FEATURE_SB_THREAD
-/* If this thread acquired an uncontested lock (old == LOCKED_BY_SELF), release it.
+/* If this thread acquired an uncontended lock (old == LOCKED_BY_SELF), release it.
  * If this thread didn't acquire the lock (old == 0 or old == 2), do nothing.
- * The only interesting case is LOCK_CONTESTED */
+ * The only interesting case is LOCK_CONTENDED */
 #define RELEASE_LOCK(th) \
   int oldval = __sync_val_compare_and_swap(&SPROF_LOCK(th), LOCKED_BY_SELF, 0); \
-  if (oldval == LOCK_CONTESTED) { \
-        oldval = __sync_val_compare_and_swap(&SPROF_LOCK(th), LOCK_CONTESTED, LOCKED_BY_OTHER); \
-        gc_assert(oldval == LOCK_CONTESTED); \
+  if (oldval == LOCK_CONTENDED) { \
+        oldval = __sync_val_compare_and_swap(&SPROF_LOCK(th), LOCK_CONTENDED, LOCKED_BY_OTHER); \
+        gc_assert(oldval == LOCK_CONTENDED); \
         os_sem_post(&thread_extra_data(th)->sprof_sem); \
     }
 #else
diff --git a/src/runtime/thread.c b/src/runtime/thread.c
index ede780866..c373c7f89 100644
--- a/src/runtime/thread.c
+++ b/src/runtime/thread.c
@@ -900,7 +900,7 @@ void lispmutex_wake_waiter()
                      1 +
 #endif
         (int*)&m->uw_state;
-    *word = 0; // slam 0 in, meaning uncontested
+    *word = 0; // slam 0 in, meaning uncontended
     futex_wake(word, 1);
 }
 #endif
diff --git a/tests/futex-wait.test.sh b/tests/futex-wait.test.sh
index c88408841..231487404 100755
--- a/tests/futex-wait.test.sh
+++ b/tests/futex-wait.test.sh
@@ -33,7 +33,7 @@ strace -f -e futex -e signal=\!sigsegv -o $tracelog \
 
 (sb-thread:grab-mutex *m*)
 
-;; We need to simulate some thread observing the mutex in a contested state, while
+;; We need to simulate some thread observing the mutex in a contended state, while
 ;; the thread that currently holds it releases and re-grabs it again quickly enough
 ;; to place it in state 1, not state 2 (but having correctly notified waiters).
 ;; It's also possible to have more than 2 threads involved because any number
@@ -57,7 +57,7 @@ strace -f -e futex -e signal=\!sigsegv -o $tracelog \
 ;;; Each "spin" on the lock bit would require a system call and return.
 
 (defun test ()
-(setf (sb-thread::mutex-state *m*) 2) ; contested state
+(setf (sb-thread::mutex-state *m*) 2) ; contended state
 (setq *thr*
       (sb-thread:make-thread
        (lambda ()
@@ -67,10 +67,10 @@ strace -f -e futex -e signal=\!sigsegv -o $tracelog \
          (format t "~&thread gets mutex~%"))))
 
 ;; Give the thread some time to enter its futex wait the normal way, but observing
-;; that the initial state is already contested. Therefore it avoids doing one compare-and-swap
-;; to set it to contested. And due to the bug, it was treating the state as *always*
-;; contested even when it was not. And the optimization to avoid changing the state
-;; to contested therefore caused every futex_wait call to return immediately.
+;; that the initial state is already contended. Therefore it avoids doing one compare-and-swap
+;; to set it to contended. And due to the bug, it was treating the state as *always*
+;; contended even when it was not. And the optimization to avoid changing the state
+;; to contended therefore caused every futex_wait call to return immediately.
 (sleep .025)
 ;; Now pretend this thread grabbed/notified/re-grabbed sooner than the other thread
 ;; could execute enough of its retry loop to win the grab. i.e. it's going to sleep

-----------------------------------------------------------------------


hooks/post-receive
-- 
SBCL

_______________________________________________
Sbcl-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-commits