On Tue, Sep 25, 2001 at 11:04:20AM +0530, shyamk@eth.net wrote: > Please clear these two doubts of mine : > 1. When does a deadlock happen on a Unix/Linux system ? Hopefully never. ;) > 2. What is a deadlock ? My favorite explanation of deadlock wasn't talking about computers at all. You know the old chinese philosopher's problem, in which there are 8 philosophers having dinner at a round table, and there is one chopstick in between each of them? \ o | o / o o - - o o / o | o \ Now they all want to eat, right? So let's say that each one has an algorithm for getting the chopsticks so they can eat: Pick up the chopstick on your left. If it's not there, wait till the person next to you puts it down, and then pick it up. Then pick up the chopstick on your right. If it's not there, wait till the person next to you puts it down, and then pick it up. So, if all of the philosophers sit down to eat at the same time, each one picks up the chopstick on their left. Then they look to the right, but there's no chopstick there. So they wait. Now, you have all 8 philosophers waiting for the chopstick on their right to be put down while holding onto a chopstick in their left hand. None of them will ever put down the chopstick they already have, so there will never be a chopstick on their right. They are deadlocked. The standard solutions to deadlock involve semaphores, timeouts, and sharing of resources. (Refer to your local operating systems book for more detail.) -ben -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Ben Hartshorne ...Discarding smoothly, as we disembark, ben@hartshorne.net All thoughts that held us wiser for a moment ben.hartshorne.net Up there, alone, in the impartial dark. -M. Oliver My PGP key is at /pgp.txt. Please encrypt all communications.
Attachment:
pgpsR7LSWDyiY.pgp
Description: PGP signature