GNU bug report logs - #19581
'sleep' return value is incorrectly rounded

Previous Next

Package: guile;

Reported by: ludo <at> gnu.org (Ludovic Courtès)

Date: Tue, 13 Jan 2015 12:59:02 UTC

Severity: normal

To reply to this bug, email your comments to 19581 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#19581; Package guile. (Tue, 13 Jan 2015 12:59:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to ludo <at> gnu.org (Ludovic Courtès):
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Tue, 13 Jan 2015 12:59:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: bug-guile <at> gnu.org
Subject: 'sleep' return value is incorrectly rounded
Date: Tue, 13 Jan 2015 13:58:04 +0100
I just noticed that ‘sleep’ essentially always rounds down its return
value, which makes it unreliable, as in this example:

--8<---------------cut here---------------start------------->8---
$ time guile -c '(sigaction SIGINT +) (call-with-new-thread (lambda () (let loop () (kill (getpid) SIGINT) (loop)))) (let loop ((n 3)) (when (> n 0) (loop (sleep (pk "s" n)))))'

;;; ("s" 3)

;;; ("s" 2)

;;; ("s" 1)

real	0m0.039s
user	0m0.052s
sys	0m0.017s
--8<---------------cut here---------------end--------------->8---

Here ‘loop’ is meant to assure we sleep for roughly 3 seconds, but
because of the incorrect rounding, we end up not sleeping at all.

Ludo’.




Information forwarded to bug-guile <at> gnu.org:
bug#19581; Package guile. (Thu, 23 Jun 2016 09:03:02 GMT) Full text and rfc822 format available.

Message #8 received at 19581 <at> debbugs.gnu.org (full text, mbox):

From: Andy Wingo <wingo <at> pobox.com>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 19581 <at> debbugs.gnu.org
Subject: Re: bug#19581: 'sleep' return value is incorrectly rounded
Date: Thu, 23 Jun 2016 11:02:45 +0200
Hi :)

On Tue 13 Jan 2015 13:58, ludo <at> gnu.org (Ludovic Courtès) writes:

> I just noticed that ‘sleep’ essentially always rounds down its return
> value, which makes it unreliable, as in this example:
>
> $ time guile -c '(sigaction SIGINT +) (call-with-new-thread (lambda () (let loop () (kill (getpid) SIGINT) (loop)))) (let loop ((n 3)) (when (> n 0) (loop (sleep (pk "s" n)))))'
>
> ;;; ("s" 3)
>
> ;;; ("s" 2)
>
> ;;; ("s" 1)
>
> real	0m0.039s
> user	0m0.052s
> sys	0m0.017s
>
> Here ‘loop’ is meant to assure we sleep for roughly 3 seconds, but
> because of the incorrect rounding, we end up not sleeping at all.

Hummmmmmmmmm.

I don't think we can change anything in 2.0.  Right?

In master, how about (1) we allow sleep to take any real number, in
seconds; (2) sleep returns an inexact real number.  Then we can
deprecate usleep and "standardize" on sleeping in units of seconds.
Internally we refactor scm_std_usleep/* to take a 64-bit double for the
number of seconds to sleep and return a double for the time remaining.

WDYT?

Andy




Information forwarded to bug-guile <at> gnu.org:
bug#19581; Package guile. (Thu, 23 Jun 2016 13:10:01 GMT) Full text and rfc822 format available.

Message #11 received at 19581 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Andy Wingo <wingo <at> pobox.com>
Cc: 19581 <at> debbugs.gnu.org
Subject: Re: bug#19581: 'sleep' return value is incorrectly rounded
Date: Thu, 23 Jun 2016 15:09:22 +0200
Hello,

Andy Wingo <wingo <at> pobox.com> skribis:

> On Tue 13 Jan 2015 13:58, ludo <at> gnu.org (Ludovic Courtès) writes:
>
>> I just noticed that ‘sleep’ essentially always rounds down its return
>> value, which makes it unreliable, as in this example:
>>
>> $ time guile -c '(sigaction SIGINT +) (call-with-new-thread (lambda () (let loop () (kill (getpid) SIGINT) (loop)))) (let loop ((n 3)) (when (> n 0) (loop (sleep (pk "s" n)))))'
>>
>> ;;; ("s" 3)
>>
>> ;;; ("s" 2)
>>
>> ;;; ("s" 1)
>>
>> real	0m0.039s
>> user	0m0.052s
>> sys	0m0.017s
>>
>> Here ‘loop’ is meant to assure we sleep for roughly 3 seconds, but
>> because of the incorrect rounding, we end up not sleeping at all.
>
> Hummmmmmmmmm.
>
> I don't think we can change anything in 2.0.  Right?
>
> In master, how about (1) we allow sleep to take any real number, in
> seconds; (2) sleep returns an inexact real number.  Then we can
> deprecate usleep and "standardize" on sleeping in units of seconds.
> Internally we refactor scm_std_usleep/* to take a 64-bit double for the
> number of seconds to sleep and return a double for the time remaining.

Sounds like a plan.  There could be programs that will break if ‘sleep’
gives them an inexact instead of an integer.  Maybe we can assume this
is an unlikely situation, though.

Thoughts?

Ludo’.




Information forwarded to bug-guile <at> gnu.org:
bug#19581; Package guile. (Mon, 27 Jun 2016 08:11:01 GMT) Full text and rfc822 format available.

Message #14 received at 19581 <at> debbugs.gnu.org (full text, mbox):

From: Andy Wingo <wingo <at> pobox.com>
To: Arne Babenhauserheide <arne_bab <at> web.de>
Cc: guile-devel <at> gnu.org, arne.babenhauserheide <at> kit.edu, 19581 <at> debbugs.gnu.org
Subject: Re: [PATCH] Allow giving floating point values to (sleep).
Date: Mon, 27 Jun 2016 10:10:13 +0200
On Sun 26 Jun 2016 23:37, Arne Babenhauserheide <arne_bab <at> web.de> writes:

> ping?

Let's follow up on bug #19581.

Thanks,

Andy




This bug report was last modified 7 years and 298 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.