gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
DrainManager Class Reference

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 DrainManagerinstance ()
 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...
 

Detailed Description

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.

Note
A System might not be completely drained even though the DrainManager has caused the simulation loop to exit. Draining needs to be restarted until all Drainable objects declare that they don't need further simulation to be completely drained. See Drainable for more information.

Definition at line 94 of file drain.hh.

Constructor & Destructor Documentation

DrainManager::DrainManager ( )
private

Definition at line 52 of file drain.cc.

References Running.

DrainManager::DrainManager ( DrainManager )
privatedelete
DrainManager::~DrainManager ( )
private

Definition at line 58 of file drain.cc.

Member Function Documentation

bool DrainManager::allInState ( DrainState  state) const
private

Helper function to check if all Drainable objects are in a specific state.

Definition at line 177 of file drain.cc.

References _allDrainable, and state().

Referenced by resume().

size_t DrainManager::drainableCount ( ) const
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().

static DrainManager& DrainManager::instance ( )
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().

bool DrainManager::isDrained ( ) const
inline

Check if the system is drained.

Definition at line 140 of file drain.hh.

References _state, and Drained.

Referenced by init_drain().

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().

DrainState DrainManager::state ( ) const
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.

Returns
true if all objects were drained successfully, false if more simulation is needed.

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().

Member Data Documentation

std::vector<Drainable *> DrainManager::_allDrainable
private

Set of all drainable objects.

Definition at line 172 of file drain.hh.

Referenced by allInState(), drainableCount(), preCheckpointRestore(), registerDrainable(), resume(), tryDrain(), and unregisterDrainable().

std::atomic_uint DrainManager::_count
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().

DrainManager DrainManager::_instance
staticprivate

Singleton instance of the drain manager.

Definition at line 185 of file drain.hh.

Referenced by instance().

DrainState DrainManager::_state
private

Global simulator drain state.

Definition at line 182 of file drain.hh.

Referenced by isDrained(), preCheckpointRestore(), resume(), state(), and tryDrain().

std::mutex DrainManager::globalLock
mutableprivate

Lock protecting the set of drainable objects.

Definition at line 169 of file drain.hh.

Referenced by drainableCount(), registerDrainable(), and unregisterDrainable().


The documentation for this class was generated from the following files:

Generated on Fri Jun 9 2017 13:04:08 for gem5 by doxygen 1.8.6