How are mutexes implemented?

static_rtti picture static_rtti · Sep 28, 2009 · Viewed 44.3k times · Source

Are some implementations better than others for specific applications? Is there anything to earn by rolling out your own?

Answer

Adamski picture Adamski · Sep 28, 2009

Check out the description of the Test-and-set machine instruction on Wikipedia, which alludes to how atomic operations are achieved at the machine level. I can imagine most language-level mutex implementations rely on machine-level support such as Test-and-set.