On Tue, 25 Sep 2001 [EMAIL PROTECTED] wrote: > Please clear these two doubts of mine : > 1. When does a deadlock happen on a Unix/Linux system ? > 2. What is a deadlock ?
Deadlock isn't a Unix/Linux concept, it's a programming concept. It happens when you have two processes or threads and two resources. Both processes want to control both resources. But process A has resource X and process B has resource Y. Process A is blocked waiting for resource Y and process B is blocked waiting for resource X. As a result neither process ever runs. (And to make it worse they have gotten stuck holding the resources, too, so nobody else can use them either). Deadlock can happen on any system that has lockable resources and multiple processes/threads that can lock them. The generally accepted way to avoid this is to make sure that all your threads in your program request resources in the same order.