Hyman's Incorrect "Solution" to the Critical Section Problem


This is an example of something that appears to be an adequate
solution to the critical section problem for two processes, yet
which does not really meet the requirements either of mutual
exclusion or bounded waiting.

This "solution" was invented, submitted to a scholarly journal, checked by
the editor and one or more referees, and none of them realized the
algorithm was flawed.  The algorithm was published in the journal and it
had to be "retracted" when it was later discovered to be incorrect!

(Harris Hyman, Comments on a problem in concurrent programming control,
Communications of the ACM, v.9 n.1, p.45, Jan. 1966)

initially turn=0, flag[0]=flag[1]=false ;
Each of two processes, P0 and P1 executes the code below, P0
executes Protocol(0,1), and P1 executes Protocol(1,0).

void Protocol (int me, int you)
1.        flag[me] = true ;
2.        while (turn != me)
3.             while (flag[you])
4.               /* do nothing */ ;
5.             turn = me
6.        CriticalSection(me) ;
7.        flag[me] = false ;
8.        RemainderSection(me) ;
        } while (true) ;

Here is a "scenario" that shows one way in which mutual
exclusion can fail when two processes P0 and P1 execute
procedure "Protocol" above:
initially turn=0, flag[0]=flag[1]=false ;

P1 executes 1, 2, 3
(since flag[0] was false, the next
 instruction P1 will execute is 5.)

P0 then executes 1, 2, 6

P1 executes 5, 6

and now P0 and P1 are both in their critical sections.

Your assignment: Figure out and write another "scenario."  This
scenario must show instead that it is possible for the bounded
waiting condition to fail if two processes P0 and P1
concurrently execute procedure "Protocol."