Deadlocks in Blocking Non-Buffered Operations: Consider the following simple exchange of messages that can lead to a deadlock:
1 P0 P1
2
3 send(&a, 1, 1); send(&a, 1, 0);
4 receive(&b, 1, 1); receive(&b, 1, 0);
The code fragment makes the values of
available to both processes
and
. However, if the send and receive operations are implemented using a blocking non-buffered protocol, the send at
waits for the matching receive at
whereas the send at process
waits for the corresponding receive at
, resulting in an infinite wait. Deadlocks are very easy in blocking protocols and care must be taken to break cyclic waits of the nature outlined.