Open main menu

lensowiki β

Changes

Computer Science/162/proj1

65 bytes added, 00:00, 5 October 2008
m
Implementation: lol
==WaitUntil()==
===Implementation===
;New state variables
Alarm has a new instance variable, waitingThreads, which is a Java PriorityQueue of waiting threads with the target wake time as their priority. It also contains a new inner class named waitingThread, which contains a reference to the KThread and its associated wakeTime.
=FIX ME I AM WRONG=
 
;Implementation details
* waitUntil() creates a new instance of waitingThread, which will associate the currentThread with the give time argument. It will then add this waitingThread instance to the PriorityQueue and put the current thread to sleep. This method is atomic.
* timerInterrupt() peek at the first WaitingThread in the waitQueue and check if its associated wake time is less than or equal to the current time. If it is, this method will pop the WaitingThread off the waitQueue and wake the associated thread. This process is repeated until the wake time of the first WaitingThread is greater than the current time.
===Testing===
1,277
edits