The idea behind mutexes is to only allow one thread access to a section of memory at any one time. If one thread locks the mutex, any other lock attempts will block until th
Here's a quick overview of what a mutex needs to work, it's a shortened form of my complete article How does a mutex work?
compare_and_swap function that can atomically attempt to modify that value and report whether it succeeded. This allows a thread to both check and modify the state at the same time.futex. This will place the thread in a queue, and also monitor the integer in memory.