Changes

Jump to: navigation, search

Computer Science/162/proj1

228 bytes added, 23:18, 4 October 2008
Implementation
===Implementation===
Condition2 has a new state variable waitQueue, a ThreadQueue with transferPriority flag set to false.
* In the sleep() method, we disable interrupts, the calling (current) thread is added to the waitQueue of threads, the corresponding lock is released, and the current thread is put to sleep. When it wakes up, interrupts are re-enabled and the thread attempts to reacquire the condition lockand interrupts are re-enabled. * The wake() method disables interrupts and checks if retrieves the next thread from the waitQueue is empty. If it the thread returned is notnull, the method readies the first that thread in the waitQueuecalls ready(). Finally, wake() re-enables the interrupts. * The wakeAll() method also disables the interrupts and stored the next thread from the waitQueue as nextThread. While nextThread is not null, the method will call wake() as long ready that thread and reset nextThread as the next thread from the waitQueue. This procedure continues until there are no more threads still in the waitQueue.
===Testing===
Anonymous user

Navigation menu