Incorrect Algorithm No. 4: One More Try

CONCEPT: To avoid the deadlock problem of Algorithm 3, we periodically clear and reset our own flag while waiting for the other one.

INITIALIZATION:

	typedef char boolean;
	...
	shared boolean flags[n -1];
	...
	flags[i ] = FREE;
	...
	flags[j ] = FREE;
	...
ENTRY PROTOCOL (for Process ):
	/* claim the resource */
	flags[] = BUSY;
-->
	/* wait if the other process is using the resource */
	while (flags[] == BUSY) {
		flags[] = FREE;
		delay a while ;
		flags[] = BUSY;
	}
EXIT PROTOCOL (for Process ):
	/* release the resource */
	flags[] = FREE;
ANALYSIS: This is the most promising solution, but alas, we still have a problem with bounded waiting . Suppose Process continually reenters its entry protocol after leaving its exit protocol, while Process is waiting. It is possible  That Process will repeatedly reach the while test when Process has temporarily cleared its flag. We cannot place a bound on how many times this could happen.