X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ftarget-unithread.lisp;h=4fc86d5f92580f8152845a2b6ffea2b6b3f79291;hb=15d6e7c9a2c3234f95dfe278046fa2fee1b0c007;hp=6eb1df2dbcdcb9e2556c06e58aba5ea14d817c14;hpb=15e14ef1ccd3ab6f4711632435a40493dc4cdd9d;p=sbcl.git diff --git a/src/code/target-unithread.lisp b/src/code/target-unithread.lisp index 6eb1df2..4fc86d5 100644 --- a/src/code/target-unithread.lisp +++ b/src/code/target-unithread.lisp @@ -1,3 +1,14 @@ +;;;; 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") ;;; used bu debug-int.lisp to access interrupt contexts @@ -11,6 +22,8 @@ (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 @@ -92,16 +105,19 @@ (return t)) (setf old-value t1)))) -(defmacro with-mutex ((mutex &key value (wait-p t)) &body body) - (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)))) +(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? commented ;;; functions are the thread versions, just to remind me what they do