Lecture 18
Lecture 18
• Multiple instances
• When a process gets all its resources it must return them in a finite
amount of time
Data Structures for the Banker’s Algorithm
Let n = number of processes, and m = number of resources types.
4. If Finish [i] == true for all i, then the system is in a safe state
Resource-Request Algorithm for Process Pi
Alloc Need
X Y Z X Y Z
P0 1 2 1 1 0 3
P1 2 0 1 0 1 2
P2 2 2 1 1 2 0
An operating system uses the banker’s algorithm for deadlock
avoidance when managing the allocation of three resource types X, Y, and Z to three
processes P0, P1, and P2. The table given below presents the current system state.
Here, the Allocation matrix shows the current number of resources of each type
allocated to each process and the Max matrix shows the maximum number of
resources of each type required by each process during its execution.
There are 3 units of type X, 2 units of type Y and 2 units of type Z still available. Is
the system is currently in safe state.
Allocation Max
X Y Z X Y Z
P0 0 0 1 8 4 3
P1 3 2 0 6 2 0
P2 2 1 1 3 3 3
Execute the Round Robin Scheduling algorithm with q=4
Pid BT AT
P1 5 0
P2 6 2
P3 3 4
P4 1 1
P5 5 6
P6 4 8