1 ;;;; unithread stub support for threads in the target machine
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
12 (in-package "SB!THREAD")
14 ;;; used bu debug-int.lisp to access interrupt contexts
15 #!-sb-fluid (declaim (inline sb!vm::current-thread-offset-sap))
16 (defun sb!vm::current-thread-offset-sap (n)
17 (declare (type (unsigned-byte 27) n))
18 (sb!sys:sap-ref-sap (alien-sap (extern-alien "all_threads" (* t)))
19 (* n sb!vm:n-word-bytes)))
23 ;; spinlocks use 0 as "free" value: higher-level locks use NIL
24 (defun get-spinlock (lock offset new-value)
25 (declare (ignore lock offset new-value)))
27 (defmacro with-spinlock ((queue) &body body)
28 (declare (ignore queue))
31 ;;;; the higher-level locking operations are based on waitqueues
34 (name nil :type (or null simple-string))
38 (defstruct (mutex (:include waitqueue))
43 (defun get-mutex (lock &optional new-value (wait-p t))
44 (declare (type mutex lock))
45 (let ((old-value (mutex-value lock)))
46 (when (and old-value wait-p)
47 (error "In unithread mode, mutex ~S was requested with WAIT-P ~S and ~
48 new-value ~S, but has already been acquired (with value ~S)."
49 lock wait-p new-value old-value))
50 (setf (mutex-value lock) new-value)
53 (defun release-mutex (lock)
54 (declare (type mutex lock))
55 (setf (mutex-value lock) nil))
58 ;; FIXME need suitable stub or ERROR-signaling definitions for
59 ;; condition-wait (queue lock)
60 ;; condition-notify (queue)
64 (defun init-job-control () t)
65 (defun debugger-wait-until-foreground-thread (stream)
66 (declare (ignore stream))
68 (defun get-foreground () t)
69 (defun release-foreground (&optional next)
70 (declare (ignore next))
72 (defun terminate-session ())