What Is Mutex?

Yan Babitski
The Startup
Published in
7 min readDec 27, 2020

--

I don’t know if that is just me, but for some reason, Wikipedia articles are only good when you already know the subject. If a few years ago I would open the Wikipedia article about the mutex to learn about it, I’d likely have about the same level of understanding plus the feeling that it’s all very complex and maybe I should be doing something else.

A formal definition is not a good way to learn a new concept. It’s much better to have an illustration even though it would inevitably be somehow inaccurate. But not every illustration is good.

Mutex

Take mutex, for example. What is a good way to illustrate the concept of mutex? Well, it’s also called a lock, so: a bike lock.

Mutex is also called a “lock”

Is it a good illustration? Let’s read the Wikipedia problem definition and see if a picture of a lock would help us to understand what’s going on:

The problem which mutual exclusion addresses is a problem of resource sharing: how can a software system control multiple processes’ access to a shared resource, when each process needs exclusive control of that resource while doing its work? The mutual-exclusion solution to this makes the shared resource available only while the process is in a specific code segment called the critical section. It controls access to the shared resource by controlling each mutual execution of that part of its program…

--

--