Suspend: RTC wakeup, sleep

Richard A. Smith richard at laptop.org
Wed Jul 28 18:23:19 EDT 2010


On 07/28/2010 05:34 AM, Hal Murray wrote:

> Can somebody confirm that sleep does what I expect on suspended systems?
>
> My expectation is that the sleep timer logically ticks when suspended, but
> that the system won't get woken up when the sleep timer expires.

IIRC it does not.  The mechanics of this seem to have changed across the 
kernel over the last 2 years but I believe the overall issue that I 
faced in my scripts is the same.  Many of my scripts that run across 
resume use the the RTC clock value for delay rather than sleep.

When you resume all the kernel timers (save the system clock) are reset 
to zero.

> For example, suppose my program does a sleep(100), and shortly after that the
> system suspends.
>
> If the next wakeup is 200 seconds after the start of the sleep, my program
> should run then (along with whatever caused the wakeup).

I don't believe so...  Your program will run 100 seconds after the wakeup.

> Or if the system wakes up after 50 seconds and doesn't suspend again, my
> program should run 100 seconds after it started to sleep.
>
> If not, how does it work?

Since the timers are reset at suspend/resume its a bit unpredictable.

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.

BUT, I never did an exhaustive exploration I switched to RTC delays and 
side stepped the entire issue.

Last time I tried it seemed different than the first time but still had 
problems.

Some of my other scripts (and runin tests) also use the EC wakeup timer 
rather than the RTC.  But I've recently discovered that wakeups via the 
EC do not seem to be 100% reliable.  Currently they are 1 shot but it 
looks like I'll have to watch and see if the system really wakes up and 
then if not then re-issue the wakeup.

-- 
Richard A. Smith  <richard at laptop.org>
One Laptop per Child



More information about the Devel mailing list