Process P1 needs resources of R1, R2, R3 and R4 respectively to complete its execution. Process P1 is initially allocated resources of R1, R2, R3, and R4 respectively. The Steps for resources allotment is explained below:įirstly, Process P1 will take the available resources and satisfy its resource need, complete its execution and then release all its allocated resources. The same is the case with Process P3, which requires 4 R3 resources which is not available initially. The available free resources are of resources of R1, R2, R3, and R4 respectively, which can be used to satisfy only the requirements of process P1 only initially as process P2 requires 2 R2 resources which are not available. ![]() Unsafe State does not necessarialy cause deadlock it may or maynot causes deadlock. Unsafe State - If Operating System is not able to prevent Processes from requesting resources which can also lead to Deadlock, then the System is said to be in an Unsafe State. So, If Operating System is able to allocate or satisfy the maximum resource requirements of all the processes in any order then the system is said to be in Safe State. So all the processes were able to complete their execution in a certain order like P3->P2->P1. Safe State - In the above example, we saw that Operating System was able to satisfy the need of all three processes, P1, P2, and P3, with their resource requirements. What are those states? Let's understand these concepts. We use two words, safe and unsafe states. ![]() ![]() What if initially there was only 1 free resource available? None of the processes would be able to complete its execution. The order of execution of the processes was. So, with 2 free resources available initially, all the processes were able to complete their execution leading to Safe State. P1 can now take 4 out of the 5 free resources and complete its execution. Now, P2 after taking the three free resources, can complete its execution and then release 5 (2+3) resources. Now the three free resources which P3 released can satisfy the need of P2. If P3 takes 2 resources and completes its execution, then P3 can release its 3 (1+2) resources. Can P1, P2, and P3 satisfy their requirements? Let's try to find out.Īs only 2 resources are free for now, then only P3 can satisfy its need for 2 resources. Operating System knows that only 2 resources out of the total available resources are currently free.īut only 2 resources are free now.So it needs 2 more resources to complete its execution. P3 process needs a maximum of 3 resources and is currently allocated with 1 resource.So it needs 3 more resources to complete its execution. P2 process needs a maximum of 5 resources and is currently allocated with 2 resources.P1 is currently allocated with 5 Resources and needs 4 more to complete its execution. P1 process needs a maximum of 9 resources (Resources can be any software or hardware Resource like tape drive or printer etc.) to complete its execution.Some more information on which the processes tells the Operating System are : Let's consider three processes P1, P2, P3. If the resource allocation leads to an unsafe state, then Operating System does not proceed further with the allocation sequence. Operating System tries to allocate the resources according to the process requirements and checks if the allocation can lead to a safe state or an unsafe state. Operating System avoids Deadlock by knowing the maximum resources requirements of the processes initially, and also Operating System knows the free resources available at that time. Deadlock is a common problem in multi-processing where several processes share a specific type of mutually exclusive resource known as a soft lock or software.īut how can Operating System avoid Deadlock? ![]() Let's first understand what is Deadlock in Operating System.ĭeadlock is a situation that occurs in Operating System when any Process enters a waiting state because another waiting process is holding the demanded resource. Scopeĭeadlock Avoidance is a process used by the Operating System to avoid Deadlock. The processes need to specify the maximum resources needed to the Operating System so that the Operating System can simulate the allocation of available resources to the requesting processes and check if it is possible to satisfy the need of all the processes requirements. Deadlock Avoidance is used by Operating System to Avoid Deadlock in the System.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |