From 7cc3fb098df221f083da1d81d2327a0a5f22edf5 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 17 Jan 2017 22:38:04 +0100 Subject: DeadlockDetect now lists some tracked CS's stats. --- src/DeadlockDetect.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/DeadlockDetect.h') diff --git a/src/DeadlockDetect.h b/src/DeadlockDetect.h index ee97fd6f7..ee6dc3e22 100644 --- a/src/DeadlockDetect.h +++ b/src/DeadlockDetect.h @@ -27,10 +27,20 @@ class cDeadlockDetect : public: cDeadlockDetect(void); + ~cDeadlockDetect(); /** Starts the detection. Hides cIsThread's Start, because we need some initialization */ bool Start(int a_IntervalSec); + /** Adds the critical section for tracking. + Tracked CSs are listed, together with ownership details, when a deadlock is detected. + A tracked CS must be untracked before it is destroyed. + a_Name is an arbitrary name that is listed along with the CS in the output. */ + void TrackCriticalSection(cCriticalSection & a_CS, const AString & a_Name); + + /** Removes the CS from the tracking. */ + void UntrackCriticalSection(cCriticalSection & a_CS); + protected: struct sWorldAge { @@ -44,6 +54,13 @@ protected: /** Maps world name -> sWorldAge */ typedef std::map WorldAges; + /** Protects m_TrackedCriticalSections from multithreaded access. */ + cCriticalSection m_CS; + + /** CriticalSections that are tracked (their status output on deadlock). + Protected against multithreaded access by m_CS. */ + std::vector> m_TrackedCriticalSections; + WorldAges m_WorldAges; /** Number of secods for which the ages must be the same for the detection to trigger */ @@ -63,6 +80,9 @@ protected: a_WorldName is the name of the world whose age has triggered the detection. a_WorldAge is the age (in ticks) in which the world is stuck. */ NORETURN void DeadlockDetected(const AString & a_WorldName, Int64 a_WorldAge); + + /** Outputs a listing of the tracked CSs, together with their name and state. */ + void ListTrackedCSs(); } ; -- cgit v1.2.3