|
The Pedigree Project
0.1
|
#include <RequestQueue.h>
Inheritance diagram for RequestQueue:
Collaboration diagram for RequestQueue:Classes | |
| class | Request |
| class | RequestQueueOverrunChecker |
Public Types | |
| enum | ActionOnDuplicate { Block, NewRequest, ReturnImmediately } |
Public Member Functions | |
| RequestQueue (const String &name) | |
| virtual void | initialise () |
| virtual void | destroy () |
| MUST_USE_RESULT uint64_t | addRequest (size_t priority, uint64_t p1=0, uint64_t p2=0, uint64_t p3=0, uint64_t p4=0, uint64_t p5=0, uint64_t p6=0, uint64_t p7=0, uint64_t p8=0) |
| MUST_USE_RESULT uint64_t | addRequest (size_t priority, ActionOnDuplicate action, uint64_t p1=0, uint64_t p2=0, uint64_t p3=0, uint64_t p4=0, uint64_t p5=0, uint64_t p6=0, uint64_t p7=0, uint64_t p8=0) |
| uint64_t | addAsyncRequest (size_t priority, uint64_t p1=0, uint64_t p2=0, uint64_t p3=0, uint64_t p4=0, uint64_t p5=0, uint64_t p6=0, uint64_t p7=0, uint64_t p8=0) |
| void | halt () |
| void | resume () |
Protected Member Functions | |
| virtual uint64_t | executeRequest (uint64_t p1, uint64_t p2, uint64_t p3, uint64_t p4, uint64_t p5, uint64_t p6, uint64_t p7, uint64_t p8)=0 |
| RequestQueue (const RequestQueue &) | |
| void | operator= (const RequestQueue &) |
| virtual bool | compareRequests (const Request &a, const Request &b) |
| bool | isRequestValid (const Request *r) |
| int | work () |
| Request * | getNextRequest () |
Static Protected Member Functions | |
| static int | trampoline (void *p) |
| static int | doAsync (void *p) |
Protected Attributes | |
| Request * | m_pRequestQueue [REQUEST_QUEUE_NUM_PRIORITIES] |
| volatile bool | m_Stop |
| Mutex | m_RequestQueueMutex |
| ConditionVariable | m_RequestQueueCondition |
| ConditionVariable | m_AsyncRequestQueueCondition |
| Thread * | m_pThread |
| bool | m_Halted |
| Mutex | m_HaltAcknowledged |
| RequestQueueOverrunChecker | m_OverrunChecker |
| size_t | m_nMaxAsyncRequests |
| size_t | m_nAsyncRequests |
| size_t | m_nTotalRequests |
| String | m_Name |
Friends | |
| class | Thread |
Implements a request queue, with one worker thread performing all requests. All requests appear synchronous to the calling thread - calling threads are blocked on mutexes (so they can be put to sleep) until their request is complete.
Definition at line 41 of file RequestQueue.h.
| RequestQueue::RequestQueue | ( | const String & | name | ) |
Creates a new RequestQueue.
Definition at line 35 of file RequestQueue.cc.
References destroy(), and m_pRequestQueue.
| uint64_t RequestQueue::addAsyncRequest | ( | size_t | priority, |
| uint64_t | p1 = 0, |
||
| uint64_t | p2 = 0, |
||
| uint64_t | p3 = 0, |
||
| uint64_t | p4 = 0, |
||
| uint64_t | p5 = 0, |
||
| uint64_t | p6 = 0, |
||
| uint64_t | p7 = 0, |
||
| uint64_t | p8 = 0 |
||
| ) |
Adds an asynchronous request to the queue. Will not block.
Definition at line 282 of file RequestQueue.cc.
References addRequest(), Thread::detach(), doAsync(), ERROR, Hex, and Scheduler::instance().
Referenced by ScsiDisk::read(), Cache::release(), Cache::sync(), Cache::timer(), and ScsiDisk::write().
Here is the caller graph for this function:| uint64_t RequestQueue::addRequest | ( | size_t | priority, |
| uint64_t | p1 = 0, |
||
| uint64_t | p2 = 0, |
||
| uint64_t | p3 = 0, |
||
| uint64_t | p4 = 0, |
||
| uint64_t | p5 = 0, |
||
| uint64_t | p6 = 0, |
||
| uint64_t | p7 = 0, |
||
| uint64_t | p8 = 0 |
||
| ) |
Adds a request to the queue. Blocks until it finishes and returns the result.
| priority | The priority to attach to this request. Lower number is higher priority. |
Definition at line 118 of file RequestQueue.cc.
Referenced by addAsyncRequest(), doAsync(), ScsiDisk::flush(), ScsiDisk::read(), and Cache::sync().
Here is the caller graph for this function:| uint64_t RequestQueue::addRequest | ( | size_t | priority, |
| ActionOnDuplicate | action, | ||
| uint64_t | p1 = 0, |
||
| uint64_t | p2 = 0, |
||
| uint64_t | p3 = 0, |
||
| uint64_t | p4 = 0, |
||
| uint64_t | p5 = 0, |
||
| uint64_t | p6 = 0, |
||
| uint64_t | p7 = 0, |
||
| uint64_t | p8 = 0 |
||
| ) |
Adds a request to the queue with optional behavior on duplicate detection.
Definition at line 126 of file RequestQueue.cc.
References Semaphore::acquire(), Thread::addRequest(), compareRequests(), executeRequest(), Thread::Exit, Thread::getUnwindState(), Processor::information(), m_pRequestQueue, m_RequestQueueCondition, m_RequestQueueMutex, NOTICE, Semaphore::release(), Thread::removeRequest(), ConditionVariable::signal(), and Thread::wasInterrupted().
|
inlineprotectedvirtual |
Defaults to never comparing as equal. Used to determine duplicates when adding async requests.
Reimplemented in CacheManager, and AtaController.
Definition at line 166 of file RequestQueue.h.
Referenced by addRequest().
Here is the caller graph for this function:
|
virtual |
Destroys the queue, killing the worker thread (safely)
Definition at line 85 of file RequestQueue.cc.
References Semaphore::acquire(), Machine::getTimer(), halt(), m_pRequestQueue, m_RequestQueueMutex, and Semaphore::release().
Referenced by RequestQueue().
Here is the caller graph for this function:
|
staticprotected |
Asynchronous thread trampoline
Definition at line 262 of file RequestQueue.cc.
References addRequest().
Referenced by addAsyncRequest().
Here is the caller graph for this function:
|
protectedpure virtual |
Callback - classes are expected to inherit and override this function. It's called when a request needs to be executed (by the worker thread).
Implemented in Ohci, Ehci, Uhci, NetworkStack, CacheManager, ZombieQueue, PciAtaController, IsaAtaController, and ScsiController.
Referenced by addRequest(), and work().
Here is the caller graph for this function:
|
protected |
Get the next Request, or NULL if no available requests.
Definition at line 373 of file RequestQueue.cc.
References assert, Semaphore::getValue(), m_pRequestQueue, and m_RequestQueueMutex.
Referenced by work().
Here is the caller graph for this function:| void RequestQueue::halt | ( | ) |
Halt RequestQueue operations, but do not terminate the worker thread.
Definition at line 333 of file RequestQueue.cc.
References Semaphore::acquire(), ConditionVariable::broadcast(), Thread::join(), m_RequestQueueCondition, m_RequestQueueMutex, m_Stop, and Semaphore::release().
Referenced by destroy(), and Thread::shutdown().
Here is the caller graph for this function:
|
virtual |
Initialises the queue, spawning the worker thread.
Reimplemented in CacheManager.
Definition at line 55 of file RequestQueue.cc.
References Machine::getTimer(), Scheduler::instance(), m_Stop, trampoline(), and WARNING.
Referenced by CacheManager::initialise(), PciAtaController::PciAtaController(), and resume().
Here is the caller graph for this function:
|
protected |
Check whether the given request is still valid in terms of this RequestQueue.
Definition at line 520 of file RequestQueue.cc.
References m_pRequestQueue, and m_RequestQueueMutex.
Referenced by Thread::shutdown().
Here is the caller graph for this function:| void RequestQueue::resume | ( | ) |
Resume RequestQueue operations.
Definition at line 355 of file RequestQueue.cc.
References initialise(), and m_RequestQueueMutex.
Referenced by Thread::shutdown().
Here is the caller graph for this function:
|
staticprotected |
Thread trampoline
Definition at line 367 of file RequestQueue.cc.
References work().
Referenced by initialise().
Here is the caller graph for this function:
|
protected |
Thread worker function
Definition at line 407 of file RequestQueue.cc.
References Semaphore::acquire(), Thread::Continue, executeRequest(), Thread::Exit, getNextRequest(), Processor::information(), m_RequestQueueCondition, m_RequestQueueMutex, m_Stop, NOTICE, Semaphore::release(), Thread::ReleaseBlockingThread, Thread::removeRequest(), Semaphore::tryAcquire(), ConditionVariable::wait(), and WARNING.
Referenced by trampoline().
Here is the caller graph for this function:
|
protected |
Condition variable for verifying if we can do an async request.
Definition at line 203 of file RequestQueue.h.
|
protected |
The request queue
Definition at line 190 of file RequestQueue.h.
Referenced by addRequest(), destroy(), getNextRequest(), isRequestValid(), and RequestQueue().
|
protected |
Condition variable for verifying if items exist.
Definition at line 200 of file RequestQueue.h.
Referenced by addRequest(), halt(), and work().
|
protected |
Mutex to be held when the request queue is being changed.
Definition at line 197 of file RequestQueue.h.
Referenced by addRequest(), destroy(), getNextRequest(), halt(), isRequestValid(), resume(), and work().
|
protected |
True if the worker thread should cleanup and stop.
Definition at line 193 of file RequestQueue.h.
Referenced by halt(), initialise(), and work().
1.8.11