a) Need matrix
Need= maximum – allocation
0 0 0 0
0 7 5 0
1 0 0 1
1 1 2 1
5 6 4 0
Currently the system is in safe state since available is ( 1 5 2 2)
Safe sequence
Need of each process is compared with the available resource, if need< available the resources are allocated.
If need> available next process is compared
In the given problem
P1 is ( 0 0 0 0) and available is ( 1 5 2 2)
Since need resourse
After allocation process is completed .
Now the available resource is available=available+allocation(which was released by process p0)
= (1,5,2,2)+(0,0,1,1)
=(1,5,3,3)currently available
Now for process p2 the need( 0,7,5,0)<(1,5,3,3)
=è process is allocated
After completion the resources are released
Available = available +allocation
=(1,5,3,3)+(1,0,0,1)==è (2,5,3,4)currently available
Now for process p3 the need( 1 0 0 1)<(2,5,3,4)
=è process is allocated
After completion the resources are released
Available = available +allocation
====(2,5,3,4)+(1,3,5,1)=(3,8,8,5)
Now for process p4 the need(1 1 2 1)<(3,8,8,5)
è process is allocated
After completion the resources are released
Available = available +allocation
=(3,8,8,5)+(0 5 3 1)
=(3,13,11,6)
Now for process p5 the need(5 6 4 0)<(3,13,11,6)
è process is allocated
After completion the resources are released
Available = available +allocation
== (3, 13,11,6)+( 0 0 1 1)
=(3,13,12,7)
Therefore the safe sequence is [p1,p2,p3,p4,p5]
REQUEST FROM P1 CAN BE GRANTED IMMEDIATELY SINCE THE REQUEST IS( 0 3 2 0)
AND THE AVAILABLE IS (1 5 2 2)
2 comments:
The solution was really useful...Thanks 4 posting...
though d soln is wrong i appreciate dat at least u tried 2 put a soln.....
Post a Comment