private PriorityScheduler() { int[] schedulerStack = new int[Const.PRIORITY_SCHEDULER_STACK_SIZE]; this.pFrame = new PriorityFrame(Const.DEFAULT_PRIORITY_QUEUE_SIZE); this.prioritySchedulerImpl = new PrioritySchedulerImpl(); vm.ClockInterruptHandler.initialize(this.prioritySchedulerImpl, schedulerStack); this.rtClock = Clock.getRealtimeClock(); this.now = new AbsoluteTime(this.rtClock); rtClock.getTime(this.now); this.timeGrain = new RelativeTime(0, 0, this.rtClock); rtClock.getResolution(this.timeGrain); scheduler = this; }
@IcecapCompileMe ScjProcess move() { if (current == ScjProcess.idleProcess) { pFrame.readyQueue.insert(current); } else { current.gotoNextState(pFrame); } // Move processes from sleepingQueue to readyQueue ScjProcess process = pFrame.sleepingQueue.minimum(); rtClock.getTime(now); while (process != null && process.next.compareTo(now) <= 0) { process.state = ScjProcess.State.READY; ScjProcess t = pFrame.sleepingQueue.extractMin(); // devices.Console.println("PrSch.move:sleep --> ready: " + t.index); pFrame.readyQueue.insert(t); // look at "next" process in sleeping queue with smallest // activationTime process = pFrame.sleepingQueue.minimum(); } // get next process from readyQueue ScjProcess nextProcess = pFrame.readyQueue.extractMax(); nextProcess.state = ScjProcess.State.EXECUTING; current = nextProcess; if (current == ScjProcess.idleProcess && pFrame.sleepingQueue.heapSize == 0 && pFrame.waitQueue.heapSize == 0 && pFrame.lockQueue.heapSize == 0) { // devices.Console.println("PrioritySch.move: " + current.getTarget()); // current.getTarget().cleanUp(); // HSO: is this call of cleanUp() necessary ? Then the // TCK-test does not work return null; } else { return nextProcess; } }