gem5
|
This class coordinates draining of a System. More...
#include <drain.hh>
Public Member Functions | |
bool | tryDrain () |
Try to drain the system. More... | |
void | resume () |
Resume normal simulation in a Drained system. More... | |
void | preCheckpointRestore () |
Run state fixups before a checkpoint restore operation. More... | |
bool | isDrained () const |
Check if the system is drained. More... | |
DrainState | state () const |
Get the simulators global drain state. More... | |
void | signalDrainDone () |
Notify the DrainManager that a Drainable object has finished draining. More... | |
void | registerDrainable (Drainable *obj) |
void | unregisterDrainable (Drainable *obj) |
Static Public Member Functions | |
static DrainManager & | instance () |
Get the singleton DrainManager instance. More... | |
Private Member Functions | |
DrainManager () | |
DrainManager (DrainManager &)=delete | |
~DrainManager () | |
bool | allInState (DrainState state) const |
Helper function to check if all Drainable objects are in a specific state. More... | |
size_t | drainableCount () const |
Thread-safe helper function to get the number of Drainable objects in a system. More... | |
Private Attributes | |
std::mutex | globalLock |
Lock protecting the set of drainable objects. More... | |
std::vector< Drainable * > | _allDrainable |
Set of all drainable objects. More... | |
std::atomic_uint | _count |
Number of objects still draining. More... | |
DrainState | _state |
Global simulator drain state. More... | |
Static Private Attributes | |
static DrainManager | _instance |
Singleton instance of the drain manager. More... | |
This class coordinates draining of a System.
When draining the simulator, we need to make sure that all Drainable objects within the system have ended up in the drained state before declaring the operation to be successful. This class keeps track of how many objects are still in the process of draining. Once it determines that all objects have drained their state, it exits the simulation loop.
|
privatedelete |
|
private |
|
private |
Thread-safe helper function to get the number of Drainable objects in a system.
Definition at line 188 of file drain.cc.
References _allDrainable, globalLock, and X86ISA::lock.
Referenced by preCheckpointRestore(), resume(), signalDrainDone(), and tryDrain().
|
inlinestatic |
Get the singleton DrainManager instance.
Definition at line 103 of file drain.hh.
References _instance.
Referenced by CxxConfigManager::drain(), CxxConfigManager::drainResume(), and init_drain().
|
inline |
void DrainManager::preCheckpointRestore | ( | ) |
Run state fixups before a checkpoint restore operation.
The drain state of an object isn't stored in a checkpoint since the whole system is always going to be in the Drained state when the checkpoint is created. When the checkpoint is restored at a later stage, recreated objects will be in the Running state since the state isn't stored in checkpoints. This method performs state fixups on all Drainable objects and the DrainManager itself.
Definition at line 134 of file drain.cc.
References _allDrainable, _state, DPRINTF, drainableCount(), Drained, panic_if(), and Running.
Referenced by init_drain().
void DrainManager::registerDrainable | ( | Drainable * | obj | ) |
Definition at line 159 of file drain.cc.
References _allDrainable, globalLock, and X86ISA::lock.
Referenced by Drainable::Drainable().
void DrainManager::resume | ( | ) |
Resume normal simulation in a Drained system.
Definition at line 95 of file drain.cc.
References _allDrainable, _count, _state, allInState(), DPRINTF, drainableCount(), Drained, Draining, panic_if(), Resuming, Running, and warn_if.
Referenced by CxxConfigManager::drainResume(), and init_drain().
void DrainManager::signalDrainDone | ( | ) |
Notify the DrainManager that a Drainable object has finished draining.
Definition at line 148 of file drain.cc.
References _count, DPRINTF, drainableCount(), and exitSimLoop().
Referenced by init_drain(), and Drainable::signalDrainDone().
|
inline |
Get the simulators global drain state.
Definition at line 143 of file drain.hh.
References _state.
Referenced by allInState(), and init_drain().
bool DrainManager::tryDrain | ( | ) |
Try to drain the system.
Try to drain the system and return true if all objects are in a the Drained state at which point the whole simulator is in a consistent state and ready for checkpointing or CPU handover. The simulation script must continue simulating until the simulation loop returns "Finished drain", at which point this method should be called again. This cycle should continue until this method returns true.
Definition at line 63 of file drain.cc.
References _allDrainable, _count, _state, DPRINTF, drainableCount(), Drained, Draining, DTRACE, SimObject::name(), panic_if(), and ArmISA::status.
Referenced by CxxConfigManager::drain(), and init_drain().
void DrainManager::unregisterDrainable | ( | Drainable * | obj | ) |
Definition at line 168 of file drain.cc.
References _allDrainable, globalLock, and X86ISA::lock.
Referenced by Drainable::~Drainable().
|
private |
Set of all drainable objects.
Definition at line 172 of file drain.hh.
Referenced by allInState(), drainableCount(), preCheckpointRestore(), registerDrainable(), resume(), tryDrain(), and unregisterDrainable().
|
private |
Number of objects still draining.
This is flagged atomic since it can be manipulated by SimObjects living in different threads.
Definition at line 179 of file drain.hh.
Referenced by resume(), signalDrainDone(), and tryDrain().
|
staticprivate |
Singleton instance of the drain manager.
Definition at line 185 of file drain.hh.
Referenced by instance().
|
private |
Global simulator drain state.
Definition at line 182 of file drain.hh.
Referenced by isDrained(), preCheckpointRestore(), resume(), state(), and tryDrain().
|
mutableprivate |
Lock protecting the set of drainable objects.
Definition at line 169 of file drain.hh.
Referenced by drainableCount(), registerDrainable(), and unregisterDrainable().