Give an example of a deadlock in a system with a few processes and a single resource class. Show a situation that leads to deadlock in such a system.
For example - thread 1 is running and locks M1, but before it can lock M2, it is interrupted. Thread 2 starts running; it locks M2, when it tries to obtain and lock M1, it is blocked because M1 is already locked (by thread 1). Eventually thread 1 starts running again, and it tries to obtain and lock M2, but it is blocked because M2 is already locked by thread 2. Both threads are blocked; each is waiting for an event which will never occur.
If you like my answer hit that like button.
Get Answers For Free
Most questions answered within 1 hours.