You can turn this diagram into a dependency graph and you will see that there is a cycle. You can see that a deadlock occurs at time 7 because T2 tries to acquire a lock on x but T1 already holds the lock on x but it is waiting on a lock for y, which T2 holds. The solution, again, is to introduce locking however incorrect locking can lead to dead lock.ĭeadlock occurs when there is a conflict of a shared resource. What you want is for the transaction to be serializable, that is in no matter how you interleave the individual instruction executions, the end result will be the exact same as some serial schedule (meaning you run them one after the other with no interleaving) of the same transactions. This is $10 more than it should (your transaction is lost forever, but you still have the money). T1 T2Īfter both transactions complete, using this timeline, which is possible if you don't use any sort of locking mechanism, the account has $50 in it. Now, the numbers below, to the left, represent time steps. So, label both of your transactions T1 (you withdraw $10), and T2 (your friend withdraws $50). Note, that in programming terms, an assignment statement is a multi-step process. The ATM machine must take your input, read what is currently in your account, and then modify the amount. Consider what happens when you attempt to withdraw $10 and your friend attempts to withdraw $50 at exactly the same time. Say you and a friend have an ATM cards for the same bank account. Think of a race condition using the traditional example.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |