As you are a mid-level programmer, I assume you have at least some basic idea of what threads are, how they are different from processes, how and why we synchronize threads, mutexes, and what an atomic variable is.
Nonetheless, we will first have a quick overview of the basic concurrency concepts, namely:
- Thread: This is an independent unit of computation your operating system (OS) can run in parallel. It is different from a process in that it shares common memory with other threads. In fact, a process can contain several threads.
- Mutex: This is an abbreviation of "mutual exclusion," also known as a lock. It is a mechanism of the OS, which will block a thread if another thread has already marked the mutex as taken, or in other words, locked or acquired it.
- Synchronization: C++ standard says that a simultaneous access of...