Suspend: RTC wakeup, sleep

Richard A. Smith richard at laptop.org
Wed Jul 28 18:39:04 EDT 2010


On 07/28/2010 11:44 AM, Paul Fox wrote:

>   >  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.
>
> i'm afraid not.  your sleep will be stretched by the duration of
> the suspend.  see the following.  a 30 second sleep starts at
> 15:42:41.  the system suspends for 15 seconds, and wakes (that's
> where the "+r" gets printed) at 15:43:01 (2 seconds later than it
> expected to, btw).  the sleep terminates, and prints "sleep
> ended" and the date at 15:43:25.  that's roughly 45 seconds after
> the 30 second sleep started.
>
>      [root at xo-a7-2a-c8 dev]# touch /var/run/powerd-inhibit-suspend/1
>      [root at xo-a7-2a-c8 dev]# (date; sleep 30; echo sleep ended; date)&
>      [2] 3122
>      Wed Jul 28 15:42:41 GMT 2010
>      [root at xo-a7-2a-c8 dev]# rtcwake -s 15 -m mem; date
>      rtcwake: assuming RTC uses UTC ...
>      rtcwake: wakeup from "mem" using /dev/rtc0 at Wed Jul 28 15:42:59 2010
>
>      +rWed Jul 28 15:43:01 GMT 2010
>      [root at xo-a7-2a-c8 dev]# sleep ended
>      Wed Jul 28 15:43:25 GMT 2010

Thanks for the testing. Perhaps we can figure out exactly my problems were.

The above is the way I expected it to work in my original scripts but 
for some reason there's a problem with this somewhere.  Otherwise I 
would have never had to switch to using the RTC time for my delays.

Try your test again and put both of your commands in loops. rtcwake 
command in a loop that suspends for a brief period like 1 or 2 seconds 
and the sleep start/stop command in something that sends its output to a 
log file.  Then see if your results are similar.

I think as the sleep time starts to get small and frequent something breaks.

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



More information about the Devel mailing list