There is a total of 15 units of Rl (resource 1) and 7 units of R2 and the system is in the following state (again call it SO):


Process Max Allocation
Rl R2 Rl R2
PO 4 2 2 2
PI 5 7 4 1
P2 4 6 3 1
P3 6 4 3 2
a)      Show that the above state is a safe state. You must come up with a complete sequence of jobs.
b)  If the system is in state SO, should a request of (2,0) units by P2 be granted? You must give a sequence.
c)       If the system is in state SO, should a request of (0,2) units by P2 be granted? You must give a sequence.
d)     If the system is in state SO, should a request of (2,0) units by P3 be granted? You must give a sequence.
e)       If the system is in state SO, should a request of (1,1) units by P2 be granted? You must give a sequence.

Ans:) The above state is a safe state because: Process Max Allocation Available Need Rl R Rl R2 Rl R2 Rl R2

PO 42223620
PI 5 77 1 16
P2 4 6 6 1 1 5
P3 6 4 4 2 3 2
Now system state are in safe because we can make more request according to the Need
column of above table.
Algorithm:
Let request i be the request vector for process Ri. If Request i[j] = k , the process
Pi wants K instance of resource type Rj. When a request for resources is made by
process Pi, the following actions are taken:
1. If Request I Need i, go to step 2. Otherwise, raise an error condition, since the process had exceeded its maximum claim.
2.       If Request I Available, go to step 3, otherwise, P I must wait, since the resources are not available.
3.       Here the system pretend to have allocated the requested resources to process Pi by modifying the state as follows:
Available : = Available - Request;
Allocation : = Allocation I + Request;
Need I: Need I - Request i;
If the resulting resource - allocation state is safe, the transaction is completed and process
P i is allocated its resources.
b) If the system is in state so, should a request of (0,2) units by p2 be granted? You must
give a sequence.
Stepl: Request (P2) = (0,2)
Need(P2) = (l,5)
If Request (P2) Need(P2) than step2.
Step2: If Request (P2) (0,2) Available (3,6) than step3
Step 3: Available : = (3,6) + (0,2) = (3, 5)
Allocation(P2) = (3,1) - (0,2) = (1, 3)
Than possible sequence : <P2, P0P3P1>.
d) If the system is in state so, should a request of (2,0) units by p2 be grated? You
must give a sequence.
Request(P2) = (2, 0)
Using above algorithm
Request (P2) Need (P2)
(2,0) ! Need (P2) = (1,5)
So, error will be printed. Request is granted.
e)  If the system is in state so, should a request of (1,1) units by P2 be granted? You
must give a sequence.
Stepl: Request(P2) Need (P3)
(2,0) (3,2) than step 2.
Step 2: If Request (P3) Available
(2,0) (3,6) than step 3.
Step 3: Available : (3,6) - (2,0) = (1,6)
Allocation (P3) = (3,2) + (2,0) = (5,2)
Need (P3) = (3,2) - (2,0) = (1,2)

Than possible sequence : <P3, P1,P2,P0>.
There is a total of 15 units of Rl (resource 1) and 7 units of R2 and the system is in the following state (again call it SO): There is a total of 15 units of Rl (resource 1) and 7 units of R2 and the system is in the following state (again call it SO): Reviewed by enakta13 on August 28, 2012 Rating: 5

Search your question

Powered by Blogger.