示例#1
0
文件: Cpu.cs 项目: andy-uq/TinyOS
        public void ReleaseLock(uint lockNo)
        {
            if (lockNo == 0 || lockNo > LockCount)
            {
                return;
            }

            var @lock = Locks[lockNo - 1];

            if (@lock.Owner != CurrentProcess.Id)
            {
                return;
            }

            @lock.RefCount--;
            if (@lock.RefCount != 0)
            {
                return;
            }

            @lock.Owner    = 0;
            @lock.RefCount = 0;

            var blockingProcess = DeviceReadQueue.Dequeue(@lock.Handle);

            if (blockingProcess == null)
            {
                return;
            }

            var pcb = blockingProcess.Process;

            AcquireLock(pcb, @lock);
            ReadyQueue.Enqueue(pcb);
        }
示例#2
0
文件: Cpu.cs 项目: andy-uq/TinyOS
        public void SignalEvent(uint eventNo)
        {
            if (eventNo == 0 || eventNo > EventCount)
            {
                return;
            }

            var ev = Events[eventNo - 1];

            BlockingProcess blockingProcess;

            while ((blockingProcess = DeviceReadQueue.Dequeue(ev.Handle)) != null)
            {
                ReadyQueue.Enqueue(blockingProcess.Process);
            }
        }
示例#3
0
文件: Cpu.cs 项目: andy-uq/TinyOS
        private void TickSleepTimer()
        {
            DeviceId sleepTimer;

            if (!SleepTimer.Tick(out sleepTimer))
            {
                return;
            }

            BlockingProcess wakingProcess;

            while ((wakingProcess = DeviceReadQueue.Dequeue(sleepTimer)) != null)
            {
                ReadyQueue.Enqueue(wakingProcess.Process);
            }
        }
示例#4
0
文件: Cpu.cs 项目: andy-uq/TinyOS
        private void ReadTerminal()
        {
            uint value;

            if (!InputDevice.Get(out value))
            {
                return;
            }

            BlockingProcess wakingProcess;

            while ((wakingProcess = DeviceReadQueue.Dequeue(DeviceId.Terminal)) != null)
            {
                var process = wakingProcess.Process;
                process.Registers[wakingProcess.Argument] = value;

                ReadyQueue.Enqueue(process);
            }
        }