Suspend: RTC wakeup, sleep

John Gilmore gnu at
Thu Jul 29 04:45:38 EDT 2010

> My power logging scripts originally used 'sleep'.  But what I found was 
> that if the time-to-suspend was shorter than sleep then the script would 
> have cases where it would never run.

Are we experiencing confusion between autosuspends and lid-close suspends?

By design, autosuspends should not change the timing behavior of programs;
the idea is for the computer to act the same, but do so using less power.

I seem to recall a lot of discussion about what happens to sleeps and
other interval timers during the POSIX standardization process.  They
ended up with "POSIX clocks" which offer both realtime and monotonic
timers, so programs can specify which behavior they want.  These were
designed to deal with "time warps" when a clock is moving unusually --
either via settimeofday() or via adjtimex().  A manual suspend such as
a lid-close suspend acts like a forward time warp, in that user
processes get no chance to run, then suddenly the time is much later.
This book about internal Linux kernel architecture discusses this

My suspicion is that POSIX punted, i.e. the old Unix calls such as
sleep() have undefined behavior during time warps.  "If you want
better defined behavior, use the new POSIX calls."


More information about the Devel mailing list