161k views
4 votes
A. illustrate that the system is in a safe state by demonstrating an order in which the processes may complete.

b. if a request from process p1 arrives for (1, 1, 0, 0), can the request be granted immediately?


c. if a request from process p4 arrives for (0, 0, 2, 0), can the request be granted immediately?

User Kaho
by
4.7k points

2 Answers

2 votes

Question:

The question is incomplete. The snapshot of a system was not added. See below the remaining part of the question and the answers.

Allocation Max Available Available

ABCD ABCD ABCD

PO 2001 4212 3321

P1 31 21 5252

P2 2103 2316

P3 1312 1424

P4 1432 3665

Answer:

(a) safe sequence is P0 , P3, P4, P1, P2

(b) The request can be granted

(c) The request can be granted

Step-by-step explanation:

a.

Need Matrix

Need [i, j] = Max [i, j] – Allocation [i, j]

A B C D

P0 2 2 1 1

P1 2 1 3 1

P2 0 2 1 3

P3 0 1 1 2

P4 2 2 3 3

Available = (3 3 2 1)

1. Need(P0) < Available so, P0 can take all resources

Available = (3 3 2 1) + (2 0 0 1) (Allocation of P0) = (5 3 2 2)

2. Need(P3)<Available so, P3 will go next

Available = (5 3 2 2) + (1 3 1 2) = (6 6 3 4)

Like wise next P4, P1, P2 will get resources.

So safe sequence is P0 , P3, P4, P1, P2

b.

Request from P1 is (1 1 0 0) and Available is (3 3 2 1)

As request(P1) < Available, we can grant request

c.

Request from P4 is (0 0 2 0) and Available is (3 3 2 1)

As request(P4) < Available, we can grant request

User Algeroth
by
4.4k points
5 votes

Answer:

Answer: (b) As request(P1) < Available, we can grant request

(c) As request(P4) < Available, we can grant request

Step-by-step explanation:

Need Matrix

Need [i, j] = Max [i, j] – Allocation [i, j]

A B C D

P0 2 2 1 1

P1 2 1 3 1

P2 0 2 1 3

P3 0 1 1 2

P4 2 2 3 3

Available = (3 3 2 1)

1. Need(P0) < Available so, P0 can take all resources

Available = (3 3 2 1) + (2 0 0 1) (Allocation of P0) = (5 3 2 2)

2. Need(P3)<Available so, P3 will go next

Available = (5 3 2 2) + (1 3 1 2) = (6 6 3 4)

Like wise next P4, P1, P2 will get resources.

So safe sequence is P0 , P3, P4, P1, P2

b.

Request from P1 is (1 1 0 0) and Available is (3 3 2 1)

As request(P1) < Available, we can grant request

c.

Request from P4 is (0 0 2 0) and Available is (3 3 2 1)

As request (P4) < Available, we can grant request

User Elisheva
by
4.4k points