recategorized by
4,867 views
5 votes
5 votes

An operating system using banker’s algorithm for deadlock avoidance has ten dedicated devices (of same type) and has three processes P1, P2 and P3 with maximum resource requirements of 4, 5 and 8 respectively. There are two states of allocation of devices as follows:

State 1 Processes P1 P2 P3
  Devices allocated 2 3 4
State 2 Processes P1 P2 P3
  Devices allocated 0 2 4

Which of the following is correct?

  1. State 1 is unsafe and State 2 is safe
  2. State 1 is safe and State 2 is unsafe
  3. Both State 1 and State 2 are safe
  4. Both State 1 and State 2 are unsafe
recategorized by

1 Answer

4 votes
4 votes

Answer A

State 1:

Total number of devices allocated = 2+3+4 =9

No of devices available = 10-9 =1

  • The no of devices still needed for P1 = 4-2 =2 >1 //Cannot allocate
  • The no of devices still needed for P2 = 5-3 =2 >1 //Cannot allocate
  • The no of devices still needed for P2 = 8-4 =4 >1 //Cannot allocate

State 1 is unsafe

state 2

Total number of devices allocated = 0+2+4 =6

No of devices available = 10-6 =4

  • The no of devices still needed for P1 = 4-0 =4 =4 //Can allocate
  • The no of devices still needed for P2 = 5-2 =3 <4 //Can allocate
  • The no of devices still needed for P2 = 8-4 =4 =4 //Can allocate

State 2 is safe

Answer:

Related questions

1 votes
1 votes
2 answers
1