> Date: Thu, 03 Sep 2009 11:19:16 -0400
> From: Peter Teoh <htmldeveloper at gmail.com>
...
> My question is:   why is process switching involving the idle thread?
>  ie, why can't we just switch directly from the old to new thread?
...

Thread lock deadlock avoidance.

Thread locks are a very low-level spinlock mechanism; in order to
change the state of thread, its thread lock must be held.  This applies
when suspending or resuming a thread.  While it's unlikely to happen,
two or more processors can make scheduling decisions leading them to
exchange threads between. 
Since a processor's idle thread is never dispatched by another
processor, the idle thread is a safe intermediary point in the thread
lock dance.

Reply via email to