nachos.threads
Class Condition2

java.lang.Object
  extended by nachos.threads.Condition2

public class Condition2
extends Object

An implementation of condition variables that disables interrupt()s for synchronization.

You must implement this.

See Also:
Condition

Constructor Summary
Condition2(Lock conditionLock)
          Allocate a new condition variable.
 
Method Summary
 void sleep()
          Atomically release the associated lock and go to sleep on this condition variable until another thread wakes it using wake().
 void wake()
          Wake up at most one thread sleeping on this condition variable.
 void wakeAll()
          Wake up all threads sleeping on this condition variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Condition2

public Condition2(Lock conditionLock)
Allocate a new condition variable.

Parameters:
conditionLock - the lock associated with this condition variable. The current thread must hold this lock whenever it uses sleep(), wake(), or wakeAll().
Method Detail

sleep

public void sleep()
Atomically release the associated lock and go to sleep on this condition variable until another thread wakes it using wake(). The current thread must hold the associated lock. The thread will automatically reacquire the lock before sleep() returns.


wake

public void wake()
Wake up at most one thread sleeping on this condition variable. The current thread must hold the associated lock.


wakeAll

public void wakeAll()
Wake up all threads sleeping on this condition variable. The current thread must hold the associated lock.