Re: OpenMCL 1.0 timed-wait-on-semaphore not timing out
Gary Byers <[email protected]> Fri, 27 Jan 2006 14:23:25 -0700 (MST)
| Newsgroups | gmane.lisp.openmcl.bugs |
|---|---|
| Message-ID | <[email protected]> |
I checked in a change to the main CVS tree a moment ago.
The one-line change is:
Index: level-1/linux-files.lisp
===================================================================
RCS file: /usr/local/tmpcvs/ccl-0.14/ccl/level-1/linux-files.lisp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- level-1/linux-files.lisp 5 Oct 2005 03:24:30 -0000 1.10
+++ level-1/linux-files.lisp 27 Jan 2006 21:19:18 -0000 1.11
@@ -71,7 +71,7 @@
(when success
(return t))
(when (or (not (eql err #$EINTR))
- (>= (setq now (get-internal-run-time)) stop))
+ (>= (setq now (get-internal-real-time)) stop))
(return nil))
(unless (zerop duration)
(let* ((diff (- stop now)))
Does that fix things ?
On Fri, 27 Jan 2006, Gary Byers wrote:
> 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
>>
>>
> _______________________________________________
> Bug-openmcl mailing list
> [email protected]
> http://clozure.com/mailman/listinfo/bug-openmcl
>
>