gem5  v21.1.0.2
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
gem5::DrainManager Class Reference

#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

Definition at line 82 of file drain.hh.

Constructor & Destructor Documentation

◆ DrainManager() [1/2]

gem5::DrainManager::DrainManager ( )
private

Definition at line 53 of file drain.cc.

References gem5::Running.

◆ DrainManager() [2/2]

gem5::DrainManager::DrainManager ( DrainManager )
privatedelete

◆ ~DrainManager()

gem5::DrainManager::~DrainManager ( )
private

Definition at line 59 of file drain.cc.

Member Function Documentation

◆ allInState()

bool gem5::DrainManager::allInState ( DrainState  state) const
private

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

Definition at line 178 of file drain.cc.

References _allDrainable, and state().

Referenced by resume().

◆ drainableCount()

size_t gem5::DrainManager::drainableCount ( ) const
private

Thread-safe helper function to get the number of Drainable objects in a system.

Definition at line 189 of file drain.cc.

References _allDrainable, globalLock, and gem5::X86ISA::lock.

Referenced by preCheckpointRestore(), resume(), signalDrainDone(), and tryDrain().

◆ instance()

static DrainManager& gem5::DrainManager::instance ( )
inlinestatic

Get the singleton DrainManager instance.

Definition at line 91 of file drain.hh.

References _instance.

Referenced by gem5::CxxConfigManager::drain(), gem5::CxxConfigManager::drainResume(), and gem5::init_drain().

◆ registerDrainable()

void gem5::DrainManager::registerDrainable ( Drainable obj)

Definition at line 160 of file drain.cc.

References _allDrainable, globalLock, and gem5::X86ISA::lock.

Referenced by gem5::Drainable::Drainable().

◆ unregisterDrainable()

void gem5::DrainManager::unregisterDrainable ( Drainable obj)

Definition at line 169 of file drain.cc.

References _allDrainable, globalLock, and gem5::X86ISA::lock.

Referenced by gem5::Drainable::~Drainable().

Member Data Documentation

◆ _allDrainable

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

Set of all drainable objects.

Definition at line 183 of file drain.hh.

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

◆ _count

std::atomic_uint gem5::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 190 of file drain.hh.

Referenced by resume(), signalDrainDone(), and tryDrain().

◆ _instance

DrainManager gem5::DrainManager::_instance
staticprivate

Singleton instance of the drain manager.

Definition at line 196 of file drain.hh.

Referenced by instance().

◆ _state

DrainState gem5::DrainManager::_state
private

Global simulator drain state.

Definition at line 193 of file drain.hh.

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

◆ globalLock

std::mutex gem5::DrainManager::globalLock
mutableprivate

Lock protecting the set of drainable objects.

Definition at line 180 of file drain.hh.

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


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

Generated on Tue Sep 21 2021 12:27:30 for gem5 by doxygen 1.8.17