Guile 2.2.2: SRFI-18, condition variables, timeouts

  • Done
  • quality assurance status badge
Details
2 participants
  • David Beswick
  • Ludovic Courtès
Owner
unassigned
Submitted by
David Beswick
Severity
normal
D
D
David Beswick wrote on 14 Dec 2017 02:37
(address . bug-guile@gnu.org)
47bd4b8a-55fe-bc92-4a64-b8bdeba2e5d5@gmail.com
Hello, I'm using Guile 2.2.2 built from source as downloaded from the
project
website.

$ guile -v
guile (GNU Guile) 2.2.2


I would expect the following command to return in 5 seconds:
$ guile -c '(use-modules (srfi srfi-18)) (let ((cv
(make-condition-variable)) (m (make-mutex))) (mutex-lock! m)
(mutex-unlock! m cv 5))'

However, it returns instantly for me. This command works as expected:
$ guile -c "(use-modules ((srfi srfi-18) #:prefix srfi:)) (let ((cv
(srfi:make-condition-variable)) (m (srfi:make-mutex))) (srfi:mutex-lock!
m) (srfi:mutex-unlock! m cv (+ (current-time) 5)))"



"All synchronization primitives which take a timeout parameter accept three
types of values as a timeout, with the following meaning:

* a time object represents an absolute point in time

* an exact or inexact real number represents a relative time in seconds
from the
  moment the primitive was called

* #f means that there is no timeout"

Assuming this page is accurate, then the case in the test code
falls under the second dot point from the spec.

The source in module/srfi/srfi-18.scm seems to pass the timeout parameter
unaltered to Guile's wait-condition-variable function, and that parameter is
said in the docs to be "either a integer as returned by ‘current-time’
or a pair
as returned by ‘gettimeofday’". I think that would cause the unexpected
behaviour that I see.

I have some time at the moment where I could address this, please let me
know if
you would like me to work on a fix.

Regards,
David
L
L
Ludovic Courtès wrote on 16 Feb 2018 15:31
(name . David Beswick)(address . dlbeswick@gmail.com)(address . 29704-done@debbugs.gnu.org)
87h8qhnh09.fsf@gnu.org
Hi David,

David Beswick <dlbeswick@gmail.com> skribis:

Toggle quote (27 lines)
> I would expect the following command to return in 5 seconds:
> $ guile -c '(use-modules (srfi srfi-18)) (let ((cv
> (make-condition-variable)) (m (make-mutex))) (mutex-lock! m)
> (mutex-unlock! m cv 5))'
>
> However, it returns instantly for me. This command works as expected:
> $ guile -c "(use-modules ((srfi srfi-18) #:prefix srfi:)) (let ((cv
> (srfi:make-condition-variable)) (m (srfi:make-mutex)))
> (srfi:mutex-lock! m) (srfi:mutex-unlock! m cv (+ (current-time) 5)))"
>
>
> It's stated on the page https://srfi.schemers.org/srfi-18/srfi-18.html that:
>
> "All synchronization primitives which take a timeout parameter accept three
> types of values as a timeout, with the following meaning:
>
> * a time object represents an absolute point in time
>
> * an exact or inexact real number represents a relative time in
> seconds from the
>   moment the primitive was called
>
> * #f means that there is no timeout"
>
> Assuming this page is accurate, then the case in the test code
> falls under the second dot point from the spec.

Sorry the late reply. I believe this and a similar issue with
‘thread-sleep!’ is now fixed:


Let me know if anything’s wrong!

Thank you,
Ludo’.
Closed
?