X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ftarget-unithread.lisp;h=886ed8286dd081056b6829ce3d0f8bc7315d52ee;hb=988afd9d54ba6c8a915544822658824ab6ae0d6c;hp=e7a1917178b55d114187441874dc92ae401535ed;hpb=c10e4afc31e25003cc2500803ceb7589232e7f6b;p=sbcl.git diff --git a/src/code/target-unithread.lisp b/src/code/target-unithread.lisp index e7a1917..886ed82 100644 --- a/src/code/target-unithread.lisp +++ b/src/code/target-unithread.lisp @@ -1,27 +1,43 @@ +;;;; unithread stub support for threads in the target machine + +;;;; This software is part of the SBCL system. See the README file for +;;;; more information. +;;;; +;;;; This software is derived from the CMU CL system, which was +;;;; written at Carnegie Mellon University and released into the +;;;; public domain. The software is in the public domain and is +;;;; provided with absolutely no warranty. See the COPYING and CREDITS +;;;; files for more information. + (in-package "SB!THREAD") -#-sb-fluid (declaim (inline sb!vm::current-thread-offset-sap)) +;;; 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)) (sb!sys:sap-ref-sap (alien-sap (extern-alien "all_threads" (* t))) (* 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))) + +(defun reap-dead-threads ()) ;;;; queues, locks ;; spinlocks use 0 as "free" value: higher-level locks use NIL -(defun get-spinlock (lock offset new-value) ) +(defun get-spinlock (lock offset new-value) + (declare (ignore lock offset new-value))) (defmacro with-spinlock ((queue) &body body) + (declare (ignore queue)) `(progn ,@body)) ;;;; the higher-level locking operations are based on waitqueues (defstruct waitqueue - (name nil :type (or null simple-base-string)) + (name nil :type (or null simple-string)) (lock 0) (data nil)) @@ -55,7 +71,7 @@ (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 @@ -89,12 +105,24 @@ (return t)) (setf old-value t1)))) -(defmacro with-mutex ((mutex &key value (wait-p t)) &body body) - (declare (ignore mutex value wait-p)) - `(progn ,@body)) +(defun get-mutex (lock &optional new-value (wait-p t)) + (declare (type mutex lock)) + (let ((old-value (mutex-value lock))) + (when (and old-value wait-p) + (error "In unithread mode, mutex ~S was requested with WAIT-P ~S and ~ + new-value ~S, but has already been acquired (with value ~S)." + lock wait-p new-value old-value)) + (setf (mutex-value lock) new-value) + t)) + +(defun release-mutex (lock) + (declare (type mutex lock)) + (setf (mutex-value lock) nil)) -;;; what's the best thing to do with these on unithread? -#+NIl +;;; 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 @@ -113,11 +141,16 @@ time we reacquire LOCK and return to the caller." "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 debugger-wait-until-foreground-thread (stream) t) +(defun init-job-control () t) +(defun debugger-wait-until-foreground-thread (stream) + (declare (ignore stream)) + t) +(defun get-foreground () t) +(defun release-foreground (&optional next) + (declare (ignore next)) + t) +(defun terminate-session ())