|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnachos.threads.Scheduler
public abstract class Scheduler
Coordinates a group of thread queues of the same kind.
ThreadQueue
Constructor Summary | |
---|---|
Scheduler()
Allocate a new scheduler. |
Method Summary | |
---|---|
boolean |
decreasePriority()
If possible, lower the priority of the current thread user in some scheduler-dependent way, preferably by the same amount as would a call to increasePriority(). |
int |
getEffectivePriority()
Get the effective priority of the current thread. |
int |
getEffectivePriority(KThread thread)
Get the effective priority of the specified thread. |
int |
getPriority()
Get the priority of the current thread. |
int |
getPriority(KThread thread)
Get the priority of the specified thread. |
boolean |
increasePriority()
If possible, raise the priority of the current thread in some scheduler-dependent way. |
abstract ThreadQueue |
newThreadQueue(boolean transferPriority)
Allocate a new thread queue. |
void |
setPriority(int priority)
Set the priority of the current thread. |
void |
setPriority(KThread thread,
int priority)
Set the priority of the specified thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Scheduler()
Method Detail |
---|
public abstract ThreadQueue newThreadQueue(boolean transferPriority)
If there is no definite thread that can be said to have "access" (as in the case of semaphores and condition variables), this parameter should be false, indicating that no priority should be transferred.
The processor is a special case. There is clearly no purpose to donating priority to a thread that already has the processor. When the processor wait queue is created, this parameter should be false.
Otherwise, it is beneficial to donate priority. For example, a lock has a definite owner (the thread that holds the lock), and a lock is always released by the same thread that acquired it, so it is possible to help a high priority thread waiting for a lock by donating its priority to the thread holding the lock. Therefore, a queue for a lock should be created with this parameter set to true.
Similarly, when a thread is asleep in join() waiting for the target thread to finish, the sleeping thread should donate its priority to the target thread. Therefore, a join queue should be created with this parameter set to true.
transferPriority
- true if the thread that has
access should receive priority from the
threads that are waiting on this queue.
public int getPriority(KThread thread)
thread
- the thread to get the priority of.
public int getPriority()
public int getEffectivePriority(KThread thread)
The effective priority of a thread is the priority of a thread after taking into account priority donations.
For a priority scheduler, this is the maximum of the thread's priority and the priorities of all other threads waiting for the thread through a lock or a join.
For a lottery scheduler, this is the sum of the thread's tickets and the tickets of all other threads waiting for the thread through a lock or a join.
thread
- the thread to get the effective priority of.
public int getEffectivePriority()
public void setPriority(KThread thread, int priority)
thread
- the thread to set the priority of.priority
- the new priority.public void setPriority(int priority)
priority
- the new priority.public boolean increasePriority()
public boolean decreasePriority()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |