Each of the three processes able to holds one of the USB drives. So, when each process requests another drive, the three processes will have the deadlock situation as each process will be waiting for the USB drive to release, which is currently in use. This will result in a circular chain.
A deadlock occurrence can be detected by the resource scheduler. A resource scheduler helps OS to keep track of all the resources which are allocated to different processes. So, when a deadlock is detected, it can be resolved using the below-given methods:. Such that even a small change to occur dead that an operation which can lead to Deadlock in the future it also never allowed process to execute.
No Preemption — A resource can be released only voluntarily by the process holding it after that process has finished its task. Mutual Exclusion is a full form of Mutex. It is a special type of binary semaphore which used for controlling access to the shared resource.
It includes a priority inheritance mechanism to avoid extended priority inversion problems. Now, process P1 is holding the resource R1 and is waiting for the resource R2. At the same time, the process P2 is having the resource R2 and is waiting for the resource R1. So, the process P1 is waiting for process P2 to release its resource and at the same time, the process P2 is waiting for process P1 to release its resource.
And no one is releasing any resource. So, both are waiting for each other to release the resource. This leads to infinite waiting and no work is done here. This is called Deadlock. Let's take one real-life example to understand the concept of Deadlock in a better way.
Suppose, you are studying in a school and you are using the bus service also. So, you have to pay two fees i. Now, think of a situation, when you go for submitting the bus fee and the accountant says that you have to submit the tuition fee first and then the bus fee. So, you go to submit the tuition fees on the other counter and the accountant there said that you have to first submit the bus fees and then the tuition fees.
One way is preemption by the help of which a resource held by one process is provided to another process. The second way is to roll back , as the operating system keeps a record of the process state and it can easily make a process roll back to its previous state due to which deadlock situation can be easily eliminate.
Learn Core Java. Java Examples Java 8 Java 11 Java HTML 5 Interactive. CSS Interactive. C Language. Advanced Data Structure. Operating System. Computer Network. Computer Architecture. Android Development. Game Development. GO Language. Consider an example when two trains are coming toward each other on the same track and there is only one track, none of the trains can move once they are in front of each other.
A similar situation occurs in operating systems when there are two or more processes that hold some resources and wait for resources held by other s. For example, in the below diagram, Process 1 is holding Resource 1 and waiting for resource 2 which is acquired by process 2, and process 2 is waiting for resource 1. Skip to content. Change Language. Related Articles. CPU Scheduling.
0コメント