![]() ![]() Nothing can change, so this is a permanent blocking of the threads, and a deadlock. Thread 2 cannot proceed and it is blocked waiting for mutex lock A. Thread 1 cannot proceed and it is blocked waiting for mutex lock B. Suppose that thread 1 tries to acquire mutex lock B and thread 2 tries to acquire mutex lock A. Of course, after the call completes and the locks are reacquired, the state must be verified to be sure the intended operation is still valid.Īn example of another kind of deadlock is when two threads, thread 1 and thread 2, each acquires a mutex lock, A and B, respectively. The solution for this kind of deadlock is to avoid calling functions outside the module when you don't know whether they will call back into the module without reestablishing invariants and dropping all module locks before making the call. ![]() If a function calls some code outside the module which, through some circuitous path, calls back into any method protected by the same mutex lock, then it will deadlock too. ![]() Recursive deadlock is very easy to program by mistake.įor example, if a code monitor has every module function grabbing the mutex lock for the duration of the call, then any call between the functions within the module protected by the mutex lock immediately deadlocks. The most common error causing deadlock is self deadlock or recursive deadlock: a thread tries to acquire a lock it is already holding. Just because some thread can make progress does not mean that there is not a deadlock somewhere else. Deadlock is a permanent blocking of a set of threads that are competing for a set of resources. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |