This project implements a distributed deadlock detection algorithm using Remote Procedure Calls (RPCs) in Go. It uses probe messages and Distributed Depth-First Search (DDFS) to identify circular wait conditions in a distributed system.
✅ Fully distributed: Each process runs independently, communicating via RPC over TCP.
✅ Probe-based detection: Sends probe messages to track dependencies and detect cycles.
✅ Session-based tracking: Unique session IDs ensure correct message processing.
✅ DDFS Optimization: Prevents redundant messages by avoiding revisited nodes.
✅ Real-time logging: Logs message flow, timestamps, and deadlock detection events.
- Each process has a list of neighbor processes that it depends on.
- A process that suspects a deadlock sends a probe to its neighbors via RPC.
- The probe tracks visited nodes, forming a wait-for graph.
- If a probe returns to the origin, a deadlock is detected.
- The system logs the detected cycle and stops the probe propagation.
git clone https://github.com/sravs-01/Deadlock-detection.git
cd Deadlock-detectionEach process runs as an independent RPC server. Open multiple terminals and start each process separately.
For example, to run Process 1:
go run main.goDo this for each process in the topology.
Once all servers are running, trigger deadlock detection by sending an initial probe from Process 1. This is done automatically in the main.go file.
[P1] Listening on port 8001...
[P2] Listening on port 8002...
[P3] Listening on port 8003...
[P4] Listening on port 8004...
[P1] Sending probe to P2: Visited [1]
[P2] Sending probe to P3: Visited [1, 2]
[P3] Sending probe to P4: Visited [1, 2, 3]
[P4] Sending probe to P1: Visited [1, 2, 3, 4]
[P1] Deadlock detected! Cycle: [1, 2, 3, 4]
This means that a circular wait was detected involving processes 1 → 2 → 3 → 4 → 1.
The process topology is defined in main.go under:
processes := map[int][]int{
1: {2},
2: {3},
3: {4},
4: {1}, // Creates a cycle
}Modify this to test different scenarios.
The following diagram illustrates the process dependencies and potential deadlock cycle:
This section presents visual comparisons of the output from different versions of the deadlock detection system.
This version demonstrates basic deadlock detection using static process dependencies.
This version uses Go goroutines for concurrency, enabling faster probe handling and non-blocking communication.
This version uses RPC to simulate a truly distributed environment with client-server communication, accurate logging, and better message tracking.
Shows how each RPC server logs incoming and outgoing probe messages and detection events.
Displays how the initiating process sends the first probe and logs the traversal path.
🔹 Dynamic process addition/removal
🔹 Fault tolerance with retry mechanisms
🔹 Optimized message passing with gRPC
Offline versions are available in the docs/ folder (.pdf and .docx).
View the live version(s) here: Google Docs Project Report
This project is licensed under the MIT License.




