# povtanishq/deadlock-toolkit-c architecture

> Architecture diagram of the GitHub repository povtanishq/deadlock-toolkit-c, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/povtanishq/deadlock-toolkit-c
- Repository: https://github.com/povtanishq/deadlock-toolkit-c

## Overview

This is a small educational C toolkit for exploring operating-system deadlock handling. A user supplies process/resource counts and allocation, maximum, and availability data through the CLI, then selects safety checking, a resource request, RAG-based detection, or recovery. The CLI dispatches each operation to its algorithm and prints the result. Banker's safety checking and request handling share need calculation; RAG construction feeds cycle detection; recovery selects a victim and releases its allocations. The excerpts show these calls, but not a separate persistent store or external integration.

Main entry points: [`src/main.c`](https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/main.c) (Interactive CLI), [`src/bankers.c`](https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/bankers.c) (Safety and requests), [`src/rag.c`](https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/rag.c) (RAG construction), [`src/recovery.c`](https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/recovery.c) (Victim selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interface"]
  node_cli["Interactive CLI<br/>[main.c]"]
end

subgraph group_analysis["Deadlock analysis"]
  node_bankers["Safety and requests<br/>[bankers.c]"]
  node_need["Need calculation<br/>[bankers.c]"]
  node_rag["RAG construction<br/>[rag.c]"]
  node_cycle["Cycle detection<br/>[rag.c]"]
end

subgraph group_recovery["Recovery"]
  node_victim["Victim selection<br/>[recovery.c]"]
  node_termination["Termination recovery<br/>[recovery.c]"]
end

node_user(("Toolkit user"))

node_user -->|"enters data"| node_cli
node_cli -->|"checks or requests"| node_bankers
node_bankers -->|"calculates need"| node_need
node_bankers -->|"rechecks safety"| node_bankers
node_cli -->|"builds graph"| node_rag
node_cli -->|"checks cycles"| node_cycle
node_cli -->|"selects victim"| node_victim
node_cli -->|"releases resources"| node_termination

click node_cli "https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/main.c"
click node_bankers "https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/bankers.c"
click node_need "https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/bankers.c"
click node_rag "https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/rag.c"
click node_cycle "https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/rag.c"
click node_victim "https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/recovery.c"
click node_termination "https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/recovery.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_user toneBlue
class node_bankers,node_need,node_rag,node_cycle toneAmber
class node_victim,node_termination toneMint
```

## Components

### User interface

- [Interactive CLI](https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/main.c): `src/main.c`

### Deadlock analysis

- [Safety and requests](https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/bankers.c): `src/bankers.c`
- [Need calculation](https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/bankers.c): `src/bankers.c`
- [RAG construction](https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/rag.c): `src/rag.c`
- [Cycle detection](https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/rag.c): `src/rag.c`

### Recovery

- [Victim selection](https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/recovery.c): `src/recovery.c`
- [Termination recovery](https://github.com/povtanishq/deadlock-toolkit-c/blob/main/src/recovery.c): `src/recovery.c`

### Other components

- **Toolkit user**

## Connections

- Toolkit user → Interactive CLI: enters data (evidence: `src/main.c`)
- Interactive CLI → Safety and requests: checks or requests (evidence: `src/main.c`)
- Safety and requests → Need calculation: calculates need (evidence: `src/bankers.c`)
- Safety and requests → Safety and requests: rechecks safety (evidence: `src/bankers.c`)
- Interactive CLI → RAG construction: builds graph (evidence: `src/main.c`)
- Interactive CLI → Cycle detection: checks cycles (evidence: `src/main.c`)
- Interactive CLI → Victim selection: selects victim (evidence: `src/main.c`)
- Interactive CLI → Termination recovery: releases resources (evidence: `src/main.c`)
