Re: OpenMCL 1.0 timed-wait-on-semaphore not timing out
Gary Byers <[email protected]> Fri, 27 Jan 2006 13:46:15 -0700 (MST)
| Newsgroups | gmane.lisp.openmcl.bugs |
|---|---|
| Message-ID | <[email protected]> |
TIMED-WAIT-ON-SEMAPHORE uses GET-INTERNAL-REAL-TIME to determine when the timeout should expire. Ordinarily, it just blocks waiting on the semaphore. If it obtains the semaphore or if the wait times out, it returs correctly, but if the blocking wait is interrupted (the GC can cause this), it inconsistently and incorrectly uses GET-INTERNAL-RUN-TIME and compares the result to the result obtained from GET-INTERNAL-REAL-TIME earlier. This is almost always completely wrong, and could explain the symptoms that you report. (Prior to 1.0, the calculation of elapsed time after an interrupt happened in C code in the lisp kernel; it was presumably correct, but, since C code is generally uninterruptible, a long wait couldn't be aborted via PROCESS-INTERRUPT or ^C.) On Fri, 27 Jan 2006, Lennart Staflin wrote: > Hi, > I have run into an occasional problem with timed-wait-on-semaphore. > This is a problem in 1.0 in 0.14 it worked well. It seems that > occasionally timed-wait-on-semaphore will hang or take much longer to > time out then is should. > > Test case below, it should print something every 5 minutes. When I run > it it seldom gets past 40 iterations usually it hangs earlier. The > machine is an iBook. At first I thought the sleep had something to do > with the hang. But I observe the hang even when on external power (and > it usually don't sleep then). Testing this takes time and I'm not at > the machine all the time, i can't be 100% sure if my observations are > accurate. (Hmm, I wonder if using a shorter timeout will trigger the > hang earlier.) > > //Lennart Staflin > > > (in-package :cl-user) > > > (defvar *sem* (make-semaphore)) > > > (defun format-date (date &optional include-time) > (if date > (multiple-value-bind (second minute hour date month year) > (decode-universal-time date) > (if include-time > (format nil "~d-~2,'0d-~2,'0d ~2,'0d:~2,'0d:~2,'0d" > year month date hour minute second) > (format nil "~d-~2,'0d-~2,'0d" year month date))) > "--")) > > > (defun format-time (universal-time) (format-date universal-time t)) > > > (defun test-bug-1 () > (loop for i from 1 to 1000 > do (progn (format t "~A Looping ~A~%" > (format-time (get-universal-time)) > i) > (force-output) > (timed-wait-on-semaphore *sem* 300))) ) > > _______________________________________________ > Bug-openmcl mailing list > [email protected] > http://clozure.com/mailman/listinfo/bug-openmcl > >