(in-package "SB!THREAD")
+;;; used bu debug-int.lisp to access interrupt contexts
#!-sb-fluid (declaim (inline sb!vm::current-thread-offset-sap))
(defun sb!vm::current-thread-offset-sap (n)
(declare (type (unsigned-byte 27) n))
(* n 4)))
(defun current-thread-id ()
- (sb!sys:sap-int
- (sb!vm::current-thread-offset-sap sb!vm::thread-pid-slot)))
+ (sb!sys:sap-ref-32 (alien-sap (extern-alien "all_threads" (* t)))
+ (* sb!vm::thread-pid-slot 4)))
;;;; queues, locks
(let ((h (car (waitqueue-data queue))))
(setf (waitqueue-lock queue) 0)
(when h
- (sb!unix:unix-kill h :sigcont)))))
+ (sb!unix:unix-kill h sb!unix:sigcont)))))
;;;; mutex
(setf old-value t1))))
(defmacro with-mutex ((mutex &key value (wait-p t)) &body body)
- (declare (ignore mutex value wait-p))
- `(progn ,@body))
-
-;;; what's the best thing to do with these on unithread?
-#+NIl
+ (cond ((not wait-p)
+ `(unless (mutex-value ,mutex)
+ (unwind-protect
+ (progn
+ (setf (mutex-value ,mutex) (or ,value t))
+ ,@body)
+ (setf (mutex-value ,mutex) nil))))
+ (t
+ `(progn ,@body))))
+
+;;; what's the best thing to do with these on unithread? commented
+;;; functions are the thread versions, just to remind me what they do
+;;; there
+#+nil
(defun condition-wait (queue lock)
"Atomically release LOCK and enqueue ourselves on QUEUE. Another
thread may subsequently notify us using CONDITION-NOTIFY, at which
"Notify one of the processes waiting on QUEUE"
(signal-queue-head queue))
-
-;;;; multiple independent listeners
-
-(defvar *session-lock* nil)
+(defun maybe-install-futex-functions () nil)
;;;; job control
+(defun init-job-control () t)
(defun debugger-wait-until-foreground-thread (stream) t)
+(defun get-foreground () t)
+(defun release-foreground (&optional next) t)
+(defun terminate-session ())