0% found this document useful (0 votes)
14 views

Banker’s Algorithm Examples

Uploaded by

ga778102165
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Banker’s Algorithm Examples

Uploaded by

ga778102165
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1- You have 4 resource types (A, B, C, D) and processes (P0,P1, P2, P3, P4) as the following.

Safe sequence: P1, P3, P4,

Process Maximum Need Current Maximum


Allocation additional
ABCD ABCD ABCD ABCD
P0 7531 0100 7431 1420
P1 3222 2001 1221 0201
P2 9023 3021 6002 3423
P3 2224 2112 0112 3311
P4 4335 0223 4112 5535
1423
5758
(Deadlock)

Safe sequence: P3

Process Maximum Need Current Maximum


Allocation additional
ABCD ABCD ABCD ABCD
P0 7531 0100 7431 1420
P1 3222 2001 1221 132
P2 9023 3021 6002 (Deadlock)
P3 2224 2112 0112
P4 4335 0223 4112

Available Units of A = 1, B = 4, C =2, D= 0

- Calculate the Maximum additional using the Banker’s algorithm?

Maximum
additional
7431
1221
6002
0112
4112

- Is the system in a safe state?


No, because there is no safe sequence

-If a request from process P2 arrives for (0,2,2,0), can the request be granted?
No, the request cannot be granted because there is no sequence safe.

2- Example in slide 46 of Chapter 6.

Let’s Try this One


• Consider the following state
• Click to edit Master text styles
– Second level Maximum Current Maximum
• Process
Third level Need Allocation Additional
– Fourth level
A B C A B C A B C
» Fifth level
P0 7 5 3 0 1 0
P1 3 2 2 2 0 0
P2 9 0 2 3 0 2
P3 2 2 2 2 1 1
P4 4 3 3 0 2 2

Available Units of A = 3 , B = 3, C = 2
46

You might also like