[Bordeaux-threads-devel] Dead lock in condition wait.
rayfill
rayfill at gmail.com
Thu Mar 29 23:51:36 UTC 2012
Hi.
I use condition-wait in many acquire recursive-lock. Other thread try
to acquire recusirve-lock's lock at dead locked.
Below code reproduce a problem on Clozure CL.
---
(defvar *condition-variable* (bt:make-condition-variable))
(defvar *recursive-lock* (bt:make-recursive-lock))
(defun worker-job (out)
(bt:with-recursive-lock-held (*recursive-lock*)
(bt:with-recursive-lock-held (*recursive-lock*)
(format out "before condition wait~%")
(force-output out)
(bt:condition-wait *condition-variable* *recursive-lock*)
(format out "after condition wait~%")
(force-output out))))
(defun condition-use-in-recursive-lock ()
(let* ((out *standard-output*)
(worker (bt:make-thread (lambda () (worker-job out)))))
(sleep 1)
(format out "before condition notify~%")
(force-output out)
(bt:with-recursive-lock-held (*recursive-lock*) ; Dead lock point.
(bt:condition-notify *condition-variable*)
(format out "after condition notify~%")
(force-output out))
(bt:join-thread worker)))
(condition-use-in-recurive-lock)
---
conditon-wait is lock release and wait semaphore.
Lock object acquirable many times. but conditon-wait is release lock at once.
I make a patch at here.
https://github.com/rayfill/bordeaux-threads/commit/192124d18a2b2858e6e8aa2cc0409065992d097a
Poor english sorry...
--
rayfill at gmail.com
Jiro OKAZAKI
More information about the bordeaux-threads-devel
mailing list