Author: Simran Gautam
Course: Operating Systems – Programming Assignment #2
Language: C++ (Linux/Ubuntu)
This project implements the Banker’s Algorithm for deadlock avoidance.
The program reads a snapshot of the system state from a text file (input.txt), builds the
Allocation, Max, Need, and Available data structures, and then runs the Banker's safety
check to decide whether the system is in a safe state.
- If the system is safe, the program prints a safe sequence of processes.
- If it is not safe, it clearly reports that the system is not in a safe state.
For the sample data based on the assignment’s table, the system is safe, and one safe sequence produced by this program is:
P3 -> P1 -> P0 -> P2 -> P4
The program expects input.txt to be in the following custom format:
-
First line
number_of_processes number_of_resource_types -
Next nProc lines – Allocation matrix Row i = resources currently allocated to process Pi.
3.Next nProc lines – Max matrix Row i = maximum demand of process Pi.
4.Last line – Available vector Remaining available units of each resource type.