in Operating System
1,170 views
1 vote
1 vote
In order to prevent deadlock we try to disable any one of the necessary conditions of deadlock .Now my point of confusion is that while we have to disable Hold and wait we say that either a process must make request initially only or if before it can request for additional resources it must be able to release all the resources that are currently allocated to it .

Now in case of disabling No Preemption also we do similar things like if a process is holding some resource and requests another resource that cannot be immediately allocated to it ,then all the resources currently being held are preempted , so then what is the basic difference between the two when in both of these scenarios we are trying to release the resources from the process if it is trying to ask for some additional resources ?
in Operating System
1.2k views

1 Answer

0 votes
0 votes

No Pre-emption :     Process P1 is requesting for resource R1

                             1] if R1 is free then aloocated to P1

                             2] If R1 is not free allocated to some other process P2

                                          a) If P2 is in the execution then the process P1 has to wait

                                          b) If P2 is not in the execution it is in waiting for some other resource R2                                                then pre-empt the resource R1 and allocate it to P1

Hold and wait: 1] Allocate the resource before the start of the process

                     2] The process should release the existing resources before making new request
                          e.g. P1 request for 100 instance of R1 but allocated only 75
                         then P1 should release all the pre allocated resource before making another new                                    100 request and keep on doing requesting and releasing untill it gets all 100                                            instances .

2 Comments

"P1 request for 100 instance of R1 but allocated only 75
                            then P1 should release all the allocated resource before making another 100 request!"

when P1 is allocated 75 resources so it will request for 76 th resource na , how come 100 th request ?

0
0

2] The process should release the existing resources before making new request
                        it requested 100 instance but get only 75 didnt get all so it should                            release all the pre allocated 75 to request once again the 100                                 instances keep on doing untill it gets all the 100 instances!

0
0

Related questions