[Openmcl-devel] Semaphore troubles

James M. Lawrence llmjjmll at gmail.com
Thu May 10 11:00:39 PDT 2012

On Thu, May 10, 2012 at 12:16 PM, Erik Pearson <erik at defunweb.com> wrote:
> Hi James,
> I'm sure Gary et al. will have a fix soon -- today if past performance is
> any measure -- but for now try this. In your ccl directory (/opt/ccl/ccl in
> my system, because I install my ccl from svn in /opt/ccl), in the level-1
> directory, in the file l1-lisp-threads.lisp,  hunt down and replace the
> %nanosleep function with this:
> #-windows-target
> (defun %nanosleep (seconds nanoseconds)
>   (with-process-whostate ("Sleep")
>     (rlet ((a :timespec)
>            (b :timespec))
>  (setf (pref a :timespec.tv_sec) seconds
> (pref a :timespec.tv_nsec) nanoseconds)
>  (let ((aptr a)
> (bptr b))
>    (loop
>       (let ((result
>      (external-call #+darwin-target "_nanosleep"
>     #-darwin-target "nanosleep"
>     :address aptr
>     :address bptr
>     :signed-fullword)))
> (declare (type (signed-byte 32) result))
> (if (and (< result 0)
>  (eql (%get-errno) (- #$EINTR)))
>     (psetq aptr bptr bptr aptr)
>     (return))))))))
> All I did was remove the OS X workaround code. I'm working with the
> up-to-date trunk, v 1.9.

That appears to have fixed it. I went back and forth between the old
and new %nanosleep for good measure. Congrats to all.

Using latest lx86cl in trunk with 2 second sleeps.

With old %nanosleep:

fail at 18 iterations
fail at 32
fail at 46
fail at 11
fail at 74

With new %nanosleep:

no fail after 166 iterations
restart CCL
no fail after 189
restart CCL
no fail after 221
restart CCL
no fail after 159
restart CCL
no fail after 653 and still running

More information about the Openmcl-devel mailing list