Probe based
Probe based
Procedure Send_Probe(Initiator, Current_Process, Num_Processes)
1. If (Current_Process == Initiator):
End Procedure
Procedure Detect_Deadlock(Num_Processes)
End Procedure
C Program
#include <stdio.h>
#include <stdbool.h>
#define MAX_PROCESSES 10
int waitForGraph[MAX_PROCESSES][MAX_PROCESSES];
bool visited[MAX_PROCESSES];
bool probeSent[MAX_PROCESSES];
if (current == initiator) {
if (visited[current]) {
visited[current] = true;
if (waitForGraph[current][i] == 1) {
if (sendProbe(initiator, i, numProcesses)) {
return true;
}
}
return false;
visited[j] = false;
if (!probeSent[i]) {
if (sendProbe(i, i, numProcesses)) {
return false;
int main() {
int numProcesses;
scanf("%d", &waitForGraph[i][j]);
if (detectDeadlock(numProcesses)) {
printf("Deadlock detected!\n");
} else {
return 0;