public void Wait(KSemaphore sema, int count, uint timeoutUs, bool canHandleCallbacks) { State = KThreadState.Waiting; this.RemoveFromSchedule(); CanHandleCallbacks = canHandleCallbacks; sema.WaitingThreads.Enqueue(this); WaitingOn = KThreadWait.Semaphore; this.WaitTimeoutSetup(timeoutUs); WaitHandle = sema; WaitArgument = ( uint )count; if (canHandleCallbacks == true) { this.Kernel.CheckCallbacks(); } this.Kernel.Schedule(); }
public void Wait( KSemaphore sema, int count, uint timeoutUs, bool canHandleCallbacks ) { State = KThreadState.Waiting; this.RemoveFromSchedule(); CanHandleCallbacks = canHandleCallbacks; sema.WaitingThreads.Enqueue( this ); WaitingOn = KThreadWait.Semaphore; this.WaitTimeoutSetup( timeoutUs ); WaitHandle = sema; WaitArgument = ( uint )count; if( canHandleCallbacks == true ) this.Kernel.CheckCallbacks(); this.Kernel.Schedule(); }
public void ReleaseWait(bool clean) { if ((State == KThreadState.Waiting) || (State == KThreadState.WaitSuspended)) { switch (this.WaitingOn) { case KThreadWait.Sleep: // Nothing to do break; case KThreadWait.Delay: if (_waitTimer != null) { this.Kernel.CancelTimer(_waitTimer); } _waitTimer = null; break; case KThreadWait.Event: { KEvent ev = this.WaitHandle as KEvent; ev.WaitingThreads.Remove(this); } break; case KThreadWait.Semaphore: { KSemaphore sema = this.WaitHandle as KSemaphore; sema.WaitingThreads.Remove(this); } break; case KThreadWait.Fpl: { KFixedPool pool = this.WaitHandle as KFixedPool; pool.WaitingThreads.Remove(this); } break; case KThreadWait.Vpl: { KVariablePool pool = this.WaitHandle as KVariablePool; pool.WaitingThreads.Remove(this); } break; default: Log.WriteLine(Verbosity.Critical, Feature.Bios, "unsupported wake wait type " + this.WaitingOn.ToString() + " - ignoring"); return; } } if (State == KThreadState.WaitSuspended) { State = KThreadState.Suspended; } else { State = KThreadState.Ready; } ReleaseCount++; if (clean == true) { Kernel.Cpu.SetContextRegister(ContextID, 2, 0x800201AA); } if (State == KThreadState.Ready) { this.AddToSchedule(); } }