CS604 Two
CS604 Two
(BC230216165)
Analyze the current state of a system based on the following data, which includes:
• The available system resources,
• The resources already allocated to each process,
• The new resource requests made by each of the five processes (P0, P1, P2, P3, and P4).
Determine whether the system is in a safe state using the Banker’s Algorithm.
Given Data:
Available: A = 3, B = 2, C = 2
Allocation:
P0 = [0, 1, 0]
P1 = [2, 0, 0]
P2 = [3, 0, 3]
P3 = [2, 1, 1]
P4 = [0, 0, 2]
Request:
P0 = [0, 0, 1]
P1 = [2, 0, 2]
P2 = [0, 0, 0]
P3 = [1, 0, 0]
P4 = [0, 0, 2]
Solution:
We determine whether the system is in a safe state using the Banker’s Algorithm
Need=Request − Allocation
Using the formula:
A B C
P0 = [0, 0, 1]
P1 = [0, 0, 2]
P2 = [0, 0, 0]
P3 = [1, 0, 0]
P4 = [0, 0, 0]
Checking Saftey State Step by Step
Need = [0, 0, 1]. Available = [3, 2, 2]. P0 can be satisfied (since 0 ≤ 3, 0 ≤ 2, 1 ≤ 2). After P0
1. P0
Need = [2, 0, 2]. Available = [3, 3, 2]. P1 can be satisfied (since 2 ≤ 3, 0 ≤ 3, 2 ≤ 2). After P1
2. P1
Need = [0, 0, 0]. Available = [5, 3, 2]. P2 can be satisfied (since 0 ≤ 5, 0 ≤ 3, 0 ≤ 2). After P2
3. P2
Need = [1, 0, 0]. Available = [8, 3, 5]. P3 can be satisfied (since 1 ≤ 8, 0 ≤ 3, 0 ≤ 5). After P3
4. P3
Need = [0, 0, 2]. Available = [10, 4, 6]. P4 can be satisfied (since 0 ≤ 10, 0 ≤ 4, 2 ≤ 6). After P4
5. P4
Safe Sequence:
safe state.
P0 → P1 → P2 → P3 → P4