[En-Nut-Discussion] Fwd: sleeping in idle thread?
Matthias Ringwald
mringwal at inf.ethz.ch
Mon Jun 7 11:25:35 CEST 2004
From: Oliver Kasten <oliver.kasten at inf.ethz.ch>
Date: 7. Juni 2004 11:21:02 GMT+02:00
To: Matthias Ringwald <mringwal at inf.ethz.ch>
Subject: sleeping in idle thread?
(this mail is sent by matthias ringwald on my behalf because i'm not a
member of the list)
hi all,
as we plan to run ethernut on a device that is running on battery
(the BTnode), naturally one of our major concerns is energy
consumption. as we expect that the BTnode to be idle most of the time
waiting for some events to happen, it would be great to put the
microcontroller (and other components to, if possible) into sleep-mode.
browsing through the code of Version 3.4.2 i found a comment to this
end (see below) but couldn't find the implementation.
THREAD(NutIdle, arg)
{
/* Initialize system timers. */
NutTimerInit();
/* Create the main application thread. */
NutThreadCreate("main", main, 0, 768);
/*
* Run in an idle loop at the lowest priority. We can still
* do something useful here, like killing terminated threads
* or putting the CPU into sleep mode.
*/
NutThreadSetPriority(254);
for (;;) {
NutThreadYield();
NutThreadDestroy();
}
}
are there any comments on how to best do this?
one possibility to implement sleeping would be to put the sleep command
after the NutThreadDestroy(). this way hardware interrupts would wake
up the cpu, execute the interrupt handler. control resumes right after
the sleep command thus the for-loop would reiterate once more. are
there any implications with that? is, for example, the startup time to
long for some drivers? do you have any experiences integrating
sleep-modes into nutos.
thanks so much! best,
olli*
--
oliver kasten
eidgenössische technische hochschule zürich
distributed systems group, eth zentrum, ch-8092 zuerich, switzerland
tel: +41-1-632 06 63 fax: +41-1-632 16 59 www.inf.ethz.ch/~kasten/
More information about the En-Nut-Discussion
mailing list