0% found this document useful (0 votes)
14 views2 pages

CS604 Two

The document analyzes the state of a system using the Banker’s Algorithm based on available resources, allocations, and requests from five processes. It concludes that the system is in a safe state as all processes can be completed without deadlock, resulting in a safe sequence of P0 → P1 → P2 → P3 → P4. The analysis includes calculations of the need matrix and updates to available resources after each process completion.

Uploaded by

Ahhad Qamar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

CS604 Two

The document analyzes the state of a system using the Banker’s Algorithm based on available resources, allocations, and requests from five processes. It concludes that the system is in a safe state as all processes can be completed without deadlock, resulting in a safe sequence of P0 → P1 → P2 → P3 → P4. The analysis includes calculations of the need matrix and updates to available resources after each process completion.

Uploaded by

Ahhad Qamar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MUHAMMAD AHHAD QUMAR

(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

Total Initial Resources:


A B C
10 4 8
Available Resources:
A B C
3 2 2
Allocated Resources:
A B C
P0 = [0, 1, 0]
P1 = [2, 0, 0]
P2 = [3, 0, 3]
P3 = [2, 1, 1]
P4 = [0, 0, 2]
Requested Resources:
A B C
P0 = [0, 0, 1]
P1 = [2, 0, 2]
P2 = [0, 0, 0]
P3 = [1, 0, 0]
P4 = [0, 0, 2]
Need Matrix:

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

finishes, it releases its resources, updating Available to:[3,3,2]

Need = [2, 0, 2]. Available = [3, 3, 2]. P1 can be satisfied (since 2 ≤ 3, 0 ≤ 3, 2 ≤ 2). After P1
2. P1

finishes, it releases its resources, updating Available to:[5,3,2]

Need = [0, 0, 0]. Available = [5, 3, 2]. P2 can be satisfied (since 0 ≤ 5, 0 ≤ 3, 0 ≤ 2). After P2
3. P2

finishes, it releases its resources, updating Available to:[8,5,3]

Need = [1, 0, 0]. Available = [8, 3, 5]. P3 can be satisfied (since 1 ≤ 8, 0 ≤ 3, 0 ≤ 5). After P3
4. P3

finishes, it releases its resources, updating Available to:[10,4,6]

Need = [0, 0, 2]. Available = [10, 4, 6]. P4 can be satisfied (since 0 ≤ 10, 0 ≤ 4, 2 ≤ 6). After P4
5. P4

finishes, it releases its resources, updating Available to:[10,4,8]


Conclusion: Since all processes can be completed without any deadlock, the system is in a

Safe Sequence:
safe state.

P0 → P1 → P2 → P3 → P4

You might also like