Give an algorithmic description of the MySemP and MySemV operations, and specify how they control the two integers. Show that your system implements a locking of semaphores that is safe, live, and fair. Implement your system in LS C and test it. We now move to the problem of deadlocking due to the routing of packets in the network. Examples 1 and 2 at the beginning of this chapter showed two examples of deadlocks.
Many conditions can bring an application to a stop due to communication deadlocks.
Here are some of them. Several tasks are supposed to exchange information between each other over channels, and this time they are well synchronized, so that a ChanOut is always matched by a ChanIn. A group of n tasks must exchange information between them, in such a way that Task1 is waiting on Task2 for a message, while Task2 is waiting on Task3, and so on, until we find that Task n is waiting on Task1. These are but a few examples of possible deadlock conditions. Fortunately, the answer is no.