public override void OnThreadBlocked(Thread thread, SchedulerTime stop) { // Assert preconditions VTable.Assert(thread == Thread.CurrentThread); if (stop != SchedulerTime.MaxValue) { // Enqueue timer so that if it expires we will notice it right a way EnqueueTimer(thread, stop); } // Thread is blocked now - indicate this to dispatcher. Dispatcher will make // make sure that thread's scheduler is aware of the blockage ProcessorDispatcher.SwitchContext(ThreadState.Blocked); // We just got unblocked and happilly running. We need to remove ourselves // from the timer queue if we are unblocked by signal rather than by timeout if (thread.UnblockedBy != WaitHandle.WaitTimeout) { // One of our buddies unblocked us - remove the time out. Before we can // actually assert that we were indeed unblocked by someone. VTable.Assert(thread.UnblockedBy != WaitHandle.UninitWait); // Remove a timer from the timer queue and happilly continue! RemoveTimer(thread); } }
public override void OnThreadStop(Thread thread) { // Perform a context switch: If thread is stopped it will be cleaned up, otherwise // it is suspended and will be cleaned up latter ProcessorDispatcher.SwitchContext(ThreadState.Stopped); }
public override void OnThreadYield(Thread thread) { // Perform a context switch: If thread is runnable it will be put on a runnable queue // by dispatcher. ProcessorDispatcher.SwitchContext(ThreadState.Running); }