[Openmcl-devel] Semaphore troubles

James M. Lawrence llmjjmll at gmail.com
Wed May 9 14:38:31 PDT 2012


I should add that I spent so much time whittling this problem down
from what it used to be that I neglected to whittle it further. I got
a smallish failure case and sent it too soon.

I hope I didn't offend Clozure-ists by comparing real race conditions
in the Ruby interpreter with possible race conditions in Clozure. My
only point is that you never know when it comes to threads.

Here is a slightly smaller version of the test function which exhibits
the same failure. I understand it is my job to make it smaller, if
possible. I contributed a fix to Clozure in the past; unless someone
sees something obviously wrong with this function, I will try to
contribute again.

(defun test ()
  (let ((tasks (make-stack))
        (receiver (make-stack)))
    (loop
       :repeat 2
       :do (ccl:process-run-function
            "test"
            (lambda ()
              (loop (push-stack (funcall (or (pop-stack tasks)
                                             (return)))
                                receiver)))))
    (push-stack (lambda () (sleep 0.2) 'later) tasks)
    (push-stack (lambda () 'sooner) tasks)
    (let ((result (pop-stack receiver)))
      (assert (eq 'sooner result)))
    (let ((result (pop-stack receiver)))
      (assert (eq 'later result)))
    (push-stack nil tasks)
    (push-stack nil tasks))
  (format t "."))



More information about the Openmcl-devel mailing list