[En-Nut-Discussion] Kill the idle thread?

Nathan Moore nategoose at gmail.com
Fri Sep 10 16:51:19 CEST 2010


Unless something has changed since then, but the last time I looked the idle
thread
attempted to free up memory associated with any killed threads, then put the
processor into low power mode, and then (after something else kicked us out
of
low power mode) yields so that any other threads that are ready to run may
run.

The idle thread is also always ready to run and keeps the thread queue from
ever
being empty.  The scheduler did not know what to do if the run queue was
empty
(last I checked -- but it's been a while).

Also, the idle thread was actually the first thread created and in turn
starts the
main thread.

If the scheduler were altered to call an idle function (that did what the
idle thread
does) each time the run queue was empty you would get the benefit of the
idle
thread without having to allocate a stack for it because it would just use
the previously
running processes stack, but it may end up looking like the last thread to
run used
a lot of cpu time to some things.  This would cause issues if the last
thread to run was
just killed, though, because it would try to free the stack space used by
that thread
while using that memory as its own stack.

Nathan

On Fri, Sep 10, 2010 at 9:13 AM, Henrik Maier <hmnews at proconx.com> wrote:

> Just out of curiosity, could one kill the idle thread?
>
> Why? Just to save some resource as I anyway have main as the lowest
> priority
> thread and this is never surrendering any CPU time. So idle has no chance
> to
> ever run.
>
> Kind Regards
>
> Henrik
>
>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>



More information about the En-Nut-Discussion mailing list