contur2
Loading...
Searching...
No Matches
contur::DeadlockDetector Class Reference

Deadlock detection/prevention helper. More...

#include <deadlock_detector.h>

Public Member Functions

 DeadlockDetector ()
 ~DeadlockDetector ()
 DeadlockDetector (const DeadlockDetector &)=delete
DeadlockDetectoroperator= (const DeadlockDetector &)=delete
 DeadlockDetector (DeadlockDetector &&) noexcept
DeadlockDetectoroperator= (DeadlockDetector &&) noexcept
void onAcquire (ProcessId pid, ResourceId resource)
 Records successful acquisition of a resource by a process.
void onRelease (ProcessId pid, ResourceId resource)
 Records release of a resource by a process.
void onWait (ProcessId pid, ResourceId resource)
 Records waiting on a resource and updates wait-for graph.
bool hasDeadlock () const
 Returns true if the current wait-for graph has a cycle.
std::vector< ProcessIdgetDeadlockedProcesses () const
 Returns process IDs involved in deadlock cycles.
bool isSafeState (const std::vector< ResourceAllocation > &current, const std::vector< ResourceAllocation > &maximum, const std::vector< std::uint32_t > &available) const
 Banker's algorithm safety check.

Private Attributes

std::unique_ptr< Impl > impl_

Detailed Description

Deadlock detection/prevention helper.

Maintains a wait-for graph for cycle detection and provides Banker's safety check for allocation state validation.

Definition at line 27 of file deadlock_detector.h.

Constructor & Destructor Documentation

◆ DeadlockDetector() [1/3]

contur::DeadlockDetector::DeadlockDetector ( )

◆ ~DeadlockDetector()

contur::DeadlockDetector::~DeadlockDetector ( )

◆ DeadlockDetector() [2/3]

contur::DeadlockDetector::DeadlockDetector ( const DeadlockDetector & )
delete

◆ DeadlockDetector() [3/3]

contur::DeadlockDetector::DeadlockDetector ( DeadlockDetector && )
noexcept

Member Function Documentation

◆ getDeadlockedProcesses()

std::vector< ProcessId > contur::DeadlockDetector::getDeadlockedProcesses ( ) const
nodiscard

Returns process IDs involved in deadlock cycles.

◆ hasDeadlock()

bool contur::DeadlockDetector::hasDeadlock ( ) const
nodiscard

Returns true if the current wait-for graph has a cycle.

◆ isSafeState()

bool contur::DeadlockDetector::isSafeState ( const std::vector< ResourceAllocation > & current,
const std::vector< ResourceAllocation > & maximum,
const std::vector< std::uint32_t > & available ) const
nodiscard

Banker's algorithm safety check.

current[i].resources[r] is currently allocated count for process i, resource r. maximum[i].resources[r] is maximum demand for process i, resource r. available[r] is currently available count for resource r.

◆ onAcquire()

void contur::DeadlockDetector::onAcquire ( ProcessId pid,
ResourceId resource )

Records successful acquisition of a resource by a process.

Parameters
pidProcess that acquired resource.
resourceAcquired resource identifier.

◆ onRelease()

void contur::DeadlockDetector::onRelease ( ProcessId pid,
ResourceId resource )

Records release of a resource by a process.

Parameters
pidProcess that released resource.
resourceReleased resource identifier.

◆ onWait()

void contur::DeadlockDetector::onWait ( ProcessId pid,
ResourceId resource )

Records waiting on a resource and updates wait-for graph.

Parameters
pidWaiting process.
resourceRequested resource identifier.

◆ operator=() [1/2]

DeadlockDetector & contur::DeadlockDetector::operator= ( const DeadlockDetector & )
delete

◆ operator=() [2/2]

DeadlockDetector & contur::DeadlockDetector::operator= ( DeadlockDetector && )
noexcept

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> contur::DeadlockDetector::impl_
private

Definition at line 72 of file deadlock_detector.h.


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