Peterson's Algorithm (Mutual Exclusion)
Cosmetic issues
# include &lt;foo.h&gt;

This is ok but unusual, don't put a space between the # and include unless you have a good reason to (sometimes used to show some &quot;indentation&quot; with conditional includes).
//Shared Global variables to control processes 

Those are only used inside main, so no need to make them global. Better would be to separate the two main parts (parent vs child) in two functions, and pass the required data as arguments to those (possibly creating a nice struct to wrap the up).
*turn;

This does nothing. Remove it. Instead, add some code to check that mmap didn't fail before you proceed.
while (*flag1 &amp;&amp; *turn == 1)
while (*flag0 == 1 &amp;&amp; *turn == 0)

This isn't consistent, so the reader wonders if there is a semantic difference between the two tests. Better be explicit in both, e.g.:
while (*flag1 == 1 &amp;&amp; *turn == 1)
while (*flag0 == 1 &amp;&amp; *turn == 0)

Also your indentation is out of whack in the child part (and for the global statics), and you have extraneous empty lines in both parts.
wait(); // wait for child

The child also runs this. Not really a bug, but a bit suspicious. Move that to parent-only code.
Big issue
You have no synchronization. The reads and writes to shared memory all race. So your program might work by sheer luck, but that's not what you want in a demo for concurrent programming. Peterson's algorithm only works if the reads and writes to the flags and turn variables propagate immediately and atomically, and you have no such guarantee here. In particular, the initial writes to turn race with each other, and all the reads of flag1 for the parent race with the writes to flag1 in the child (and vice-versa). This doesn't give you that &quot;turn is set to either 0 or 1 randomly&quot;, it gives you undefined behavior.
You'll need to use some form of interprocess synchronization method to achieve correct concurrency control. POSIX named semaphores, or a pthread_mutex with the process-shared attribute set, could work (see the POSIX page for pthread_mutexattr_init for an example).