On Friday 26 May 2006 09:30, Nikodemus Siivola wrote:
> Aleksandar Bakic <a_bakic@...> writes:
> Scanning through the list, this seems to have fallen by the wayside.
> Any objections to merging this once we're out of freeze?
Well, for one thing it lacks documentation on what TIMEOUT means. I'd
prefer to see NIL as the default value of TIMEOUT (probably
WITH-TIMEOUT needs to be able to handle that too) instead of the
misleading 0 which to me implies "try to get the lock and return
immediately even if it is not available".
Plus WITH-TIMEOUT is currently broken with regards to nesting.
Obviously, this only applies if this is called within another
Oh, and there is a race so that the client cannot tell from the
(undocumented) return value if the operation was successful or not.
Futexes support timeouts, maybe using that would have better performance
and may solve the race too. What about lutexes?
> > Index: target-thread.lisp
> > ===================================================================
> > RCS file: /cvsroot/sbcl/sbcl/src/code/target-thread.lisp,v
> > retrieving revision 1.55
> > diff -u -r1.55 target-thread.lisp
> > --- target-thread.lisp 18 Nov 2005 12:28:40 -0000 1.55
> > +++ target-thread.lisp 23 Jan 2006 13:39:47 -0000
> > @@ -237,7 +237,7 @@
> > (+ (sb!kernel:get-lisp-obj-address waitqueue)
> > (- (* 3 sb!vm:n-word-bytes)
> > sb!vm:instance-pointer-lowtag))))
> > -(defun condition-wait (queue mutex)
> > +(defun condition-wait (queue mutex &key (timeout 0))
> > #!+sb-doc
> > "Atomically release MUTEX and enqueue ourselves on QUEUE.
> > Another thread may subsequently notify us using CONDITION-NOTIFY,
> > at which @@ -258,9 +258,12 @@
> > ;; this comment, it will change queue->data, and so
> > ;; futex-wait returns immediately instead of sleeping.
> > ;; Ergo, no lost wakeup
> > - (with-pinned-objects (queue me)
> > - (futex-wait (waitqueue-data-address queue)
> > - (sb!kernel:get-lisp-obj-address me))))
> > + (handler-case
> > + (sb!ext:with-timeout timeout
> > + (with-pinned-objects (queue me)
> > + (futex-wait (waitqueue-data-address queue)
> > + (sb!kernel:get-lisp-obj-address
> > me)))) + (sb!ext:timeout () nil)))
> > ;; If we are interrupted while waiting, we should do these
> > things ;; before returning. Ideally, in the case of an unhandled
> > signal, ;; we should do them before entering the debugger, but this
> > is
> -- Nikodemus Schemer: "Buddha is small, clean, and
> serious." Lispnik: "Buddha is big, has hairy armpits, and laughs."