Compare-And-Swap

Let's look at compare-and-swap hardware primitive for supporting locks, in this lesson.

We'll cover the following

Another hardware primitive that some systems provide is known as the compare-and-swap instruction (as it is called on SPARC, for example), or compare-and-exchange (as it called on x86). The C pseudocode for this single instruction is given in the code excerpt below.

Get hands-on with 1200+ tech skills courses.