[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#12248: sleep is not arware of suspend mode

From: Pádraig Brady
Subject: bug#12248: sleep is not arware of suspend mode
Date: Wed, 22 Aug 2012 09:55:42 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]