Esempio n. 1
0
        public void Wait(KEvent ev, KWaitType waitEventMode, uint userValue, uint outAddress, uint timeoutUs, bool canHandleCallbacks)
        {
            State = KThreadState.Waiting;
            this.RemoveFromSchedule();

            CanHandleCallbacks = canHandleCallbacks;

            ev.WaitingThreads.Enqueue(this);

            WaitingOn = KThreadWait.Event;
            this.WaitTimeoutSetup(timeoutUs);
            WaitHandle    = ev;
            WaitEventMode = waitEventMode;
            WaitArgument  = userValue;
            WaitAddress   = outAddress;

            if (canHandleCallbacks == true)
            {
                this.Kernel.CheckCallbacks();
            }

            this.Kernel.Schedule();
        }
Esempio n. 2
0
        public void Wait( KEvent ev, KWaitType waitEventMode, uint userValue, uint outAddress, uint timeoutUs, bool canHandleCallbacks )
        {
            State = KThreadState.Waiting;
            this.RemoveFromSchedule();

            CanHandleCallbacks = canHandleCallbacks;

            ev.WaitingThreads.Enqueue( this );

            WaitingOn = KThreadWait.Event;
            this.WaitTimeoutSetup( timeoutUs );
            WaitHandle = ev;
            WaitEventMode = waitEventMode;
            WaitArgument = userValue;
            WaitAddress = outAddress;

            if( canHandleCallbacks == true )
                this.Kernel.CheckCallbacks();

            this.Kernel.Schedule();
        }
Esempio n. 3
0
        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();
            }
        }