How to mutex the task

In reply to zz8318:

It would certainly help to describe in more detail what “didn’t work” means. What were you expecting to see and what actually happened?

I’m going to assume that you saw all 3 calls to A proceeded without waiting. That is because statements within a process are not “atomic” between concurrent processes. That means it’s. possible for one process can test the value of mutex and another process can also test before the next statement sets the mutex value back to 0. Only a semaphore and mailbox give you an atomic test and set as a single operation.