Without locking a row that was modified by a currently running transaction, Atomicity would be compromised). No matter what relational database system you are using, locks will always be acquired when modifying (e.g., UPDATE or DELETE) a certain table record. Using locking for controlling access to shared resources is prone to deadlocks, and the transaction scheduler alone cannot prevent their occurrences.įor instance, relational database systems use various locks to guarantee transaction ACID properties. So both of you are going to wait for a long very long time :) Your brother doesn't want to give the knife to you. You don't want to give the apple to your brother. Your mother gives you the apple and the knife to your brother in the beginning.īoth are happy and playing(Executing their codes).Īnyone of you wants to cut the apple(critical section) at some point. So they will wait for forever (DEADLOCK CONDITION).Ĭritical section(cutting apple with knife). So process R1 will wait for process P2 to release R2 and vice versa. Initially, the OS assigns R1 to process P1 and R2 to process P2.Īs both processes are running concurrently they may start executing their code but the PROBLEM arises when a process hits the critical section. Say there are two processes P1, P2 and two globally shareable resource R1, R2 and in critical section both resources need to be accessed Because that neither of each is going to start communication and waiting in a passive state, both will wait for the other to start communication which ends up in a deadlock situation.ĭeadlock is a common problem in multiprocessing/multiprogramming problems in OS. In this situation, both sides want to communicate each other if and only if one of them receives an I-am-sorry call from the other. You are dating with a girl and one day after an argument, both sides are heart-broken to each other and waiting for an I-am-sorry-and-I-missed-you call. Another High Level Explanation of Deadlock : Broken Hearts So simply, when two threads needs two different resources and each of them has the lock of the resource that the other need, it is a deadlock. This is an endless untrustworthy situation, because both sides are insisting the first step from each other. Also the cop is not going to let the friend of criminal let go, unless the criminal releases the hostage. In this case, criminal is not going to let the hostage go if cop won't let his friend to let go. Imagine a criminal holds an hostage and against that, a cop also holds an hostage who is a friend of the criminal. Let me explain a real world (not actually real) example for a deadlock situation from the crime movies.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |