GNU bug report logs - #12248
sleep: use realtime seconds, not relative seconds (be

Previous Next

Package: coreutils;

Reported by: Albrecht Frenzel <ajfrenzel <at> web.de>

Date: Tue, 21 Aug 2012 15:36:02 UTC

Severity: wishlist

Full log


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

From: Pádraig Brady <P <at> draigBrady.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 12248 <at> debbugs.gnu.org, Eric Blake <eblake <at> redhat.com>,
	Albrecht Frenzel <ajfrenzel <at> web.de>, Bob Proulx <bob <at> proulx.com>
Subject: Re: bug#12248: sleep is not arware of suspend mode
Date: Wed, 22 Aug 2012 09:55:42 +0100
On 08/22/2012 04:18 AM, Paul Eggert wrote:
> On 08/21/2012 05:15 PM, Pádraig Brady wrote:
>> I agree that either behavior could be required.
>> The default though should probably stay as is.
>> I.E. when the system suspends, the timeout suspends too.
> 
> But that's not what 'sleep' does, on systems where
> 'nanosleep' uses real time, which is what POSIX
> specifies.
> 
> The Linux kernel uses CLOCK_MONOTONIC for nanosleep,
> as opposed to the POSIX-specified CLOCK_REALTIME.
> This is an infelicity.  It'd be nicer if 'sleep'
> acted as if it were using a realtime clock when
> running under the Linux kernel, just as 'sleep'
> does on other POSIX systems.

POSIX states that:

"Setting  the  value  of  the CLOCK_REALTIME clock via clock_set‐
 time(2) shall have no effect on threads that are blocked waiting
 for a relative time service based upon this clock"

So I'm guessing that Linux is just using CLOCK_MONOTONIC
for consistency so that nanosleep() behaves the same,
whether or not CLOCK_REALTIME jumps due to suspend/resume
or settime().

If other system's nanosleep() are dependent on settime()
then that seems in contravention of POSIX.
If other system's nanosleep() are dependent on suspend/resume
then that seems inconsistent.

It seems like we need to specify a TIMER_ABSTIME via
clock_nanosleep() or timer_settime() to both provide
that behavior as an option and possibly reduce inconsistency
between systems.

cheers,
Pádraig.




This bug report was last modified 6 years and 331 days ago.

Previous Next


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