Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Recall the various deadlock detection and prevention algorithms we’ve discussed

ID: 3716410 • Letter: R

Question

Recall the various deadlock detection and prevention algorithms we’ve discussed in this course, and consider the following snapshot of a system with five processes (P1, P2, P3, P4, P5) and four resources (R1, R2, R3, R4).

There are no current outstanding queued unsatisfied requests.

Currently Available Resources

R1

R2

R3

R4

   0

1

2

2

Current Allocation

Max Need

Still Needs

Process

R1

R2

R3

R4

R1

R2

R3

R4

R1

R2

R3

R4

P1

2

0

1

0

2

0

3

0

0

0

2

0

P2

0

0

0

2

0

7

5

2

0

7

5

0

P3

4

0

3

0

6

6

5

6

2

6

2

6

P4

4

3

5

2

6

3

5

4

2

0

0

2

P5

2

3

3

0

2

6

5

0

0

3

2

0

Is this system currently deadlocked, or can any process become deadlocked? Why or why not? If not deadlocked, give an execution order.

If a request from a process P1 arrives for (0, 4, 2, 0), can the request be immediately granted? Why or why not? If yes, show an execution order.

iii)  If a request from a process P2 arrives for (0, 1, 2, 0), can the request be immediately granted? Why or why not? If yes, show an execution order.

R1

R2

R3

R4

   0

1

2

2

Explanation / Answer

-> currently available resources

R0   R1   R2   R3

0      1      2      2

-> At this situation only process P1 get resources for its task completion because it still needs resources

R0   R1   R2   R3

0      0      2      0

which resources are available.So first Process P1 completes its task and then releases its resources after task completion.

-> next available resources

R0 R1    R2 R3

0+2     1+0      2+1      2+0

i.e

available resources

R0   R1    R2 R3

2     1      3      2

-> At this situation only process P4 get resources for its task completion because it still needs resources

R0   R1   R2   R3

2      0      0      2

which resources are available.So next Process P4 completes its task and then releases its resources after task completion.

-> now available resources

R0    R1    R2    R3

2+4     1+3 3+5       2+2

i.e

available total resources

R0   R1    R2 R3

6       4       8       4

-> At this situation only process P5 get resources for its task completion because it still needs resources

R0   R1   R2   R3

0     3      2      0

which resources are available.So next Process P5 completes its task and then releases its resources after task completion.

-> now available resources

R0    R1    R2    R3

6+2       4+3       8+3       4+0

i.e

available total resources

R0   R1    R2 R3

8       7     11       4

-> still the order of processes execution is P1->P4->P5

-> At this situation only process P2 get resources for its task completion because it still needs resources

R0   R1   R2   R3

0      7      5      0

which resources are available.So next Process P5 completes its task and then releases its resources after task completion.

-> now available resources

R0    R1    R2    R3

8+0       7+0     11+0       4+2

i.e

available total resources

R0   R1    R2 R3

8       7     11       6

-> finally P3 got all resources to complete its task.after completion of process P3 ...total avialble resources are

R0   R1    R2    R3

12      7     14       6

=> Execution Order is :    P1->P4->P5->P2->P3

--------> if request from a process P1 arrives for (0, 4, 2, 0) at initial situation .the request can't be granted immediately,because avialable resources are less than required resources.So P1 doesnt granted immediately.

iii) If a request from a process P2 arrives for (0, 1, 2, 0) ...the request immediately granted because avialable resources are greater than required resources.

then Execution order is : P2 -> P1 -> P4 -> P5 -> P3 (similarily as above)