Race condition is when output depends on the order of execution of processes.
Suppose we have two processes sharing variable:
counter = 5
P1()
{
Critical Section
if counter == 6
exit;
counter --;
}
P2()
{
Critical section
if counter == 4
exit;
counter ++;
}
If p1 is executed before p2 then value of counter = 4
If p2 is executed before p1 then value of counter = 6
We have mutual exclusion in critical section but still race condition exists.
From Wikipedia: Race condition becomes a bug when events do not happen in the order the programmer intended.
But above needed that race condition.