0% found this document useful (0 votes)
5 views3 pages

Fall 2024 - CS604 - 2

The document presents a solution to determine if a system is in a safe state using the Banker’s Algorithm, analyzing available resources, allocations, and requests. It includes input data, allocation and request matrices, and a step-by-step execution of the algorithm, concluding that the system is in a safe state with a safe sequence of process execution. Key components such as the Need Matrix and Work Vector are also discussed to illustrate the algorithm's functionality.

Uploaded by

Tayyab Najeeb
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)
5 views3 pages

Fall 2024 - CS604 - 2

The document presents a solution to determine if a system is in a safe state using the Banker’s Algorithm, analyzing available resources, allocations, and requests. It includes input data, allocation and request matrices, and a step-by-step execution of the algorithm, concluding that the system is in a safe state with a safe sequence of process execution. Key components such as the Need Matrix and Work Vector are also discussed to illustrate the algorithm's functionality.

Uploaded by

Tayyab Najeeb
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/ 3

CS604 Assignment Solution

Student Name: Tayyab Najeeb


Student ID: BC230206185

Solution:

The problem requires determining whether a system is in a safe state using the Banker’s
Algorithm. The analysis involves evaluating the system’s current state based on:

 Available resources.
 Resources already allocated to processes.
 Resource requests from processes.
A system is in a safe state if it can allocate resources to all processes in some order without
causing a deadlock.

 Input Data

Resource A B C
Available 3 2 2

 Allocation Matrix

Process A B C
P0 0 1 0
P1 2 0 0
P2 3 0 3
P3 2 1 1
P4 0 0 2

 Request Matrix
Process 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 (Calculated as Request – Allocation)

Process A B C
P0 0 0 1
P1 0 0 2
P2 -3 0 -3
P3 -1 -1 -1
P4 0 0 0

 Banker’s Algorithm Execution


Step-by-Step Process

Step Process Selected Work Before Work After Allocation Safe Sequence
Allocation
1 P2 [3, 2, 2] [6, 2, 5] P2
2 P0 [6, 2, 5] [6, 3, 5] P2 → P0
3 P3 [6, 3, 5] [8, 4, 6] P2 → P0 → P3
4 P1 [8, 4, 6] [10, 4, 6] P2 → P0 → P3 → P1
5 P4 [10, 4, 6] [10, 4, 8] P2 → P0 → P3 → P1 → P4

Conclusion:

Outcome Details
Safe State Yes, the system is in a safe state.
Safe Sequence P2 → P0 → P3 → P1 → P4

Additional Notes
 Banker’s Algorithm: A deadlock avoidance algorithm that ensures the system remains in
a safe state.
 Need Matrix: Represents the additional resources each process requires to complete
execution.
 Work Vector: Tracks available resources at each step, ensuring that the processes can
safely proceed.
This tabular representation provides a structured and concise explanation of the problem and
solution using the Banker’s Algorithm.

You might also like