QtxAcqHistTracker: implement heuristic gridlock detector
This commit is contained in:
@@ -63,7 +63,9 @@ namespace smo {
|
||||
*/
|
||||
|
||||
bool QutexAcquisitionHistoryTracker
|
||||
::heuristicallyTraceContinuationHistoryForGridlockOn(Qutex &firstFailedQutex)
|
||||
::heuristicallyTraceContinuationHistoryForGridlockOn(
|
||||
Qutex &firstFailedQutex,
|
||||
std::shared_ptr<AsynchronousContinuationChainLink>& currentContinuation)
|
||||
const
|
||||
{
|
||||
/** HEURISTIC APPROACH:
|
||||
@@ -80,6 +82,34 @@ const
|
||||
* explanation.
|
||||
*/
|
||||
|
||||
// Iterate through all entries in the acquisition history
|
||||
for (const auto& entry : acquisitionHistory) {
|
||||
const auto& continuation = entry.first;
|
||||
const auto& historyEntry = entry.second;
|
||||
|
||||
// Skip the current continuation (don't compare with itself)
|
||||
if (continuation == currentContinuation) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if firstFailedQutex is in this continuation's held locks
|
||||
const std::unique_ptr<std::forward_list<std::reference_wrapper<Qutex>>>&
|
||||
heldLocks = historyEntry.second;
|
||||
|
||||
if (!heldLocks)
|
||||
{ continue; }
|
||||
|
||||
for (const auto& heldLock : *heldLocks)
|
||||
{
|
||||
/* Found firstFailedQutex in another continuation's held locks
|
||||
* This indicates a potential gridlock
|
||||
*/
|
||||
if (&heldLock.get() == &firstFailedQutex) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user