The Gateway to Computer Science Excellence

+2 votes

Consider a system with twelve magnetic tape drives and three processes $P_1, P_2$ and $P_3$. process $P_1$ requires maximum ten tape drives, process $P_2$ may need as many as four tape drives and $P_3$ may need upto nine tape drives. Suppose that at time $t_1$, process $P_1$ is holding five tape drives, process $P_2$ is holding two tape drives and process $P_3$ is holding three tape drives, At time $t_1$, system is in:

- safe state
- unsafe state
- deadlocked state
- starvation state

+3 votes

Best answer

**System is in UNSAFE state**

- P1 holds 5 tapes
- P2 holds 2 tapes
- P3 holds 3 tapes

*Total 10 tapes are allocated and 12-10=2 tapes are free*

- P1 requires maximum 10 tape drives; It needs 10-5 =
*5 more tapes* - P2 may need as many as 4tape drives. It needs 4-2=
*2 more tapes.* - P3 may need as many as 9 tape drives. It needs 9-3=
*6 more tapes.*

We can allocate 2 free tapes to P2.

P2 will complete execution and release all its resources including 4 tapes.

Even if we allocate 4 tapes to ** P1 or P3 they cannot complete execution **because P1 nees 5 more taps while P3 needs 6 more tapes.

+3 votes

At time T1

Maximum need P1 P2 P3

10 4 9

Allocated P1 P2 P3

5 2 3

Total tape drives = 12

Available tape drives = 12-(Allocated tape drives)

= 12 - (10)=2

Need P1 P2 P3

5 2 6

So process P2 needs 2 tap drives and we have available 2.

So P2 satisfies is need at t1 After this Available becomes 4

So we can see neither P1 nor P3 need satisfies so system no longer becomes

safe and System goes to unsafe state at time t1

0 votes

System is unsafe .

Explanation

Processes | Used | Max | Need |

P1 | 5 | 10 | 5 |

P2 | 2 | 4 | 2 |

P3 | 3 | 9 | 6 |

Now Available A=12-(5+3+2)=2

Anew=2,With Anew we can only fulfil the desire of P2

Now Anew=2+2=4

Anew=4::: With Anew=4 we are totaly unable to fulfill the need of P1 and P3.So there is no sequence exist by which we can say system in safe.

52,218 questions

59,890 answers

201,083 comments

118,128 users