On Thu, 03 Sep 2009 19:04:36 +0200, John Zolnowsky x69422/408-404-5064 <John.Zolnowsky at sun.com> wrote:
>> 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. John, fwiw, I have a hard time finding this in either swtch() http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/disp/disp.c#849 or disp() which is picking up the next kthread for swtch() http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/disp/disp.c#disp iei. I do miss were we'd switch from kthread_A->idle_thread->kthread_B in there. can you point me to the proper place ? thanks! frankB
