The Pedigree Project
0.1
|
#include <AsidManager.h>
Public Types | |
typedef uint8_t | Asid |
Public Member Functions | |
Asid | obtainAsid () |
void | returnAsid (Asid asid) |
void | bulldoze (Asid asid) |
Static Public Member Functions | |
static AsidManager & | instance () |
Private Member Functions | |
AsidManager () | |
~AsidManager () | |
Private Attributes | |
uint32_t | m_Asids [NUM_ASID] |
Mutex | m_Mutex |
Static Private Attributes | |
static AsidManager | m_Instance |
MIPS TLB entries are marked with an ASID - an address space identifier. There are only 256 of these available (on the R4000) so they have to be managed in some way.
We have the policy that all processes in the "Ready" or "Running" state have ASIDs assigned. When a thread goes to sleep it must relinquish its ASID.
There is a use case where we have >256 running processes - This is handled by every process calling our function 'bulldoze' just before it is scheduled. Normally 'bulldoze' will do nothing, but in the case where there is contention for its ASID the entire TLB will be flushed of any entry containing that ASID.
Definition at line 44 of file AsidManager.h.
typedef uint8_t AsidManager::Asid |
ASID typedef
Definition at line 48 of file AsidManager.h.
|
private |
Default constructor
Definition at line 31 of file AsidManager.cc.
|
private |
Destructor - not implemented.
Definition at line 35 of file AsidManager.cc.
void AsidManager::bulldoze | ( | AsidManager::Asid | asid | ) |
If the ASID given is contended, flush the TLB of all references to it.
Definition at line 87 of file AsidManager.cc.
Referenced by obtainAsid().
|
static |
Gets the instance of the AsidManager
Definition at line 26 of file AsidManager.cc.
References m_Instance.
AsidManager::Asid AsidManager::obtainAsid | ( | ) |
Returns an ASID. The TLB is flushed of all references to that ASID.
Definition at line 39 of file AsidManager.cc.
References Semaphore::acquire(), bulldoze(), m_Asids, m_Mutex, panic(), and Semaphore::release().
void AsidManager::returnAsid | ( | AsidManager::Asid | asid | ) |
Takes an ASID. The given ASID is returned to the pool of usable ASIDs.
Definition at line 75 of file AsidManager.cc.
References Semaphore::acquire(), ERROR, m_Asids, m_Mutex, and Semaphore::release().
|
private |
The array of ASID to instance count.
Definition at line 70 of file AsidManager.h.
Referenced by obtainAsid(), and returnAsid().
|
staticprivate |
The static AsidManager instance - singleton class.
Definition at line 76 of file AsidManager.h.
Referenced by instance().
|
private |
Our lock, to protect the integrity of our data.
Definition at line 73 of file AsidManager.h.
Referenced by obtainAsid(), and returnAsid().