|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnachos.threads.ThreadQueue
public abstract class ThreadQueue
Schedules access to some sort of resource with limited access constraints. A thread queue can be used to share this limited access among multiple threads.
Examples of limited access in Nachos include:
All thread queue methods must be invoked with interrupts disabled.
Constructor Summary | |
---|---|
ThreadQueue()
|
Method Summary | |
---|---|
abstract void |
acquire(KThread thread)
Notify this thread queue that a thread has received access, without going through request() and nextThread(). |
abstract KThread |
nextThread()
Notify this thread queue that another thread can receive access. |
abstract void |
print()
Print out all the threads waiting for access, in no particular order. |
abstract void |
waitForAccess(KThread thread)
Notify this thread queue that the specified thread is waiting for access. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ThreadQueue()
Method Detail |
---|
public abstract void waitForAccess(KThread thread)
A thread must not simultaneously wait for access to multiple resources. For example, a thread waiting for a lock must not also be waiting to run on the processor; if a thread is waiting for a lock it should be sleeping.
However, depending on the specific objects, it may be acceptable for a thread to wait for access to one object while having access to another. For example, a thread may attempt to acquire a lock while holding another lock. Note, though, that the processor cannot be held while waiting for access to anything else.
thread
- the thread waiting for access.public abstract KThread nextThread()
If the limited access object transfers priority, and if there are other threads waiting for access, then they will donate priority to the returned thread.
public abstract void acquire(KThread thread)
This method should not be called for a thread returned from nextThread().
thread
- the thread that has received access, but was not
returned from nextThread().public abstract void print()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |