# Does mutual exclusion hold in this case?

I entered into a discussion with a friend on the following question, which asks if mutual exclusion holds:

Consider two processes:

$s_1$ and $s_2$ are two variables, set equal initially.

P1:

1. while $s_1 = s_2$: wait.

2. /execute critical section/

3. $s_1$ is set such that it is not equal to $s_2$

P2:

1. while $s_1 = s_2$: wait.

2. /execute critical section/

3. $s_1$ is set such that it is not equal to $s_2$

My friend argues that mutual exclusion holds. His explanation:

Mutual Exclusion holds if the following implication holds: If a process is in its critical section, then other processes should not be allowed in their critical sections.

Consider this implication as $P \to Q$. He argues that since the premise $P$ is wrong (because none of P1 and P2 are in their critical sections), the implication is true and hence mutual exclusion holds.

Whereas my thinking is that when none of the processes get to enter their critical section, talking about mutual exclusion is pointless and hence the property doesn't hold.

Is the implication way of thinking the correct approach? I feel that it's not, but I have not been able to prove my intuition.

• What worries me here that this is wrong at more than one level. 1. the current version deadlocks right away. 2. one could be tempted in switching the $=$ in P2's step 1 for $\neq$ and vice versa in step 3. Now the deadlock is gone but it's wrong again. Maybe discuss with your friend why. – Kai Dec 6 '16 at 9:16
• Mutual exclusion is a safety property: it simply states that bad things do not happen. A stuck system like that satisfies safety. Then there are liveness properties, requiring that good things do happen eventually. The algorithm above fails liveness. – chi Dec 6 '16 at 10:46
• @Kai: It was just a puzzle kind of thing we were discussing. I agree that this is not a proper solution for the critical section problem. – pratz Dec 6 '16 at 11:16