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

Banker’s Algorithm: Safe State Analysis

Uploaded by

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

Banker’s Algorithm: Safe State Analysis

Uploaded by

Hasan Tahsin
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Banker’s Algorithm for multiple resource types.

Consider a system with 4 processes: P1 through P4 and 3 resource types: A (9 units) B (3


units), C ( 6 units). Current allocation of resources and maximum
requirements of a process for each resource are given below. Determine whether the current
state of this system is safe or not.

A B C

A B C
P1 3 2 2
CA = P1 1 0 0 ​ MaxReq =
​ P2 6 1 3
P2 6 1 2
P3 3 1 4
P3 2 1 1
P4 4 2 2
P4 0 0 2

________________________________________________________________________

The request matrix is denoted with R and array A denotes the available resource counts. We
assume that all processes request their maximum required resources all at once.

A B C
R= ​​ ​ A = (0 1 1)​
P1 2 2 2

P2 0 0 1

P3 1 0 3

P4 4 2 0

Since R(P2) < A (0 1 1), process P2 is served first.

A B C
CA = ​ ​ and ​ A = (0 1 0)​
P1 1 0 0

P2 6 1 3

P3 2 1 1

P4 0 0 2

P2 runs to completion and releases all its acquired resources. Hence, A = (6 2 3)


A B C

P1 2 2 2
R=
P2 _ _ _

P3 1 0 3

P4 4 2 0

Since R(P1) < A (6 2 3), process P1 is served. [Note that here you can choose P1 or P3 or P4.
In case of multiple candidate rows, you can choose any]

A B C
CA = ​ ​ and ​ A = (4 0 1)​
P1 3 2 2

P2 0 0 0

P3 2 1 1

P4 0 0 2

P1 runs to completion and releases all its acquired resources. Hence, A = (7 2 3)

A B C

R= P1 _ _ _

P2 _ _ _

P3 1 0 3

P4 4 2 0

Since R(P3) < A (7 2 3), process P3 is served.


A B C
CA = ​ ​ and ​ A = (6 2 0)
P1 0 0 0

P2 0 0 0

P3 3 1 4

P4 0 0 2

P3 runs to completion and releases all its acquired resources. Hence, A = (9 3 4)

Similarly, since R(P4) < A (9 2 3), process P4 is served.

Hence, we obtain a scheduling order: P2 -> P1 -> P3 -> P4.


Since there exists at least one scheduling order such that every process runs to completion
even if all of them request their maximum required resources all at once, the given state is a
safe state.

You might also like