|
Rockbox mail archiveSubject: time to sleep?time to sleep?
From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 22 Aug 2002 13:36:55 +0200 (MET DST) The SH-1 CPU has a SLEEP mode that makes the CPU halt and consume 20mA less current, to be awaken again on an interrupt. (It "typicaly" uses 60 mA in ordinary operation and 40 mA while sleeping, at 12.5MHz.)[1] It takes 3 cycles to reach the state (it is a CPU instruction). Here's how I figure we can make use of this: o We add a new thread with only one purpose: go to sleep when all tasks have done their "important" stuff. o We wake up automaticly on the timer tick, every 50 ms. We then continue "business as usual". o Threads should mark themselves as "busy" even when they use yield() or similar functions if they want full-speed. One example of this would be the mpeg thread reading more data but still doing occational yield()s. This allows us to run as long as we have to without sleeping as long as we are "busy". I haven't thought out exactly how to mark the thread "busy" or how to make it "not busy" again. I'm open for suggestions. o The sleep thread basicly perform this little loop: while(1) { if(!threads_busy) SLEEP; yield(); } If done correctly, this will basicly allow all threads to do what they need to do each "round" and then we sleep until there's time to go to work again. Pretty much like going to work each day. ;-) [1] = Details are found in section 19 and 20 in the SH-1 HW manual: http://rockbox.haxx.se/docs/sh7032h.pdf -- Daniel "Bagder" Stenberg -- http://rockbox.haxx.se/Received on 2002-08-22 Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy |