[Ecls-list] Query about changes
Juan Jose Garcia-Ripoll
juanjose.garciaripoll at googlemail.com
Sat Sep 5 21:44:56 UTC 2009
Hi Matthew,
thanks for reporting the problem. There are a couple of subtle race
conditions that may happen with locks (even SBCL's current code has
it). I have designed with-lock in the following way
(defmacro with-lock ((lock) &body body)
#-threads
`(progn , at body)
;; Why do we need %count? Even if get-lock succeeeds, an interrupt may
;; happen between the end of get-lock and when we save the output of
;; the function. That means we lose the information and ignore that
;; the lock was actually acquired. Furthermore, a lock can be recursive
;; and mp:lock-holder is also not reliable.
#+threads
`(let* ((%the-lock ,lock)
(%count (mp:lock-count %the-lock)))
(unwind-protect
(progn
(mp::get-lock %the-lock)
, at body)
(when (> (mp:lock-count %the-lock) %count)
(mp::giveup-lock %the-lock)))))
I will commit this later on. It should solve your problems.
Juanjo
--
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com
More information about the ecl-devel
mailing list