nachos.threads
Class PriorityScheduler.ThreadState

java.lang.Object
  extended by nachos.threads.PriorityScheduler.ThreadState
Enclosing class:
PriorityScheduler

protected class PriorityScheduler.ThreadState
extends Object

The scheduling state of a thread. This should include the thread's priority, its effective priority, any objects it owns, and the queue it's waiting for, if any.

See Also:
KThread.schedulingState

Field Summary
protected  int priority
          The priority of the associated thread.
protected  KThread thread
          The thread with which this object is associated.
 
Constructor Summary
PriorityScheduler.ThreadState(KThread thread)
          Allocate a new ThreadState object and associate it with the specified thread.
 
Method Summary
 void acquire(PriorityScheduler.PriorityQueue waitQueue)
          Called when the associated thread has acquired access to whatever is guarded by waitQueue.
 int getEffectivePriority()
          Return the effective priority of the associated thread.
 int getPriority()
          Return the priority of the associated thread.
 void setPriority(int priority)
          Set the priority of the associated thread to the specified value.
 void waitForAccess(PriorityScheduler.PriorityQueue waitQueue)
          Called when waitForAccess(thread) (where thread is the associated thread) is invoked on the specified priority queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

thread

protected KThread thread
The thread with which this object is associated.


priority

protected int priority
The priority of the associated thread.

Constructor Detail

PriorityScheduler.ThreadState

public PriorityScheduler.ThreadState(KThread thread)
Allocate a new ThreadState object and associate it with the specified thread.

Parameters:
thread - the thread this state belongs to.
Method Detail

getPriority

public int getPriority()
Return the priority of the associated thread.

Returns:
the priority of the associated thread.

getEffectivePriority

public int getEffectivePriority()
Return the effective priority of the associated thread.

Returns:
the effective priority of the associated thread.

setPriority

public void setPriority(int priority)
Set the priority of the associated thread to the specified value.

Parameters:
priority - the new priority.

waitForAccess

public void waitForAccess(PriorityScheduler.PriorityQueue waitQueue)
Called when waitForAccess(thread) (where thread is the associated thread) is invoked on the specified priority queue. The associated thread is therefore waiting for access to the resource guarded by waitQueue. This method is only called if the associated thread cannot immediately obtain access.

Parameters:
waitQueue - the queue that the associated thread is now waiting on.
See Also:
ThreadQueue.waitForAccess(nachos.threads.KThread)

acquire

public void acquire(PriorityScheduler.PriorityQueue waitQueue)
Called when the associated thread has acquired access to whatever is guarded by waitQueue. This can occur either as a result of acquire(thread) being invoked on waitQueue (where thread is the associated thread), or as a result of nextThread() being invoked on waitQueue.

See Also:
ThreadQueue.acquire(nachos.threads.KThread), ThreadQueue.nextThread()