Concurrency & the Hardware

Two cores reaching for the same shared counter at once, and the three fixes for it: a lock, an atomic add, and giving each core its own copy.
Before you start. Processes, Threads & the Kernel gave you a thread, one flow of instructions moving through a program, and a process, the box that can hold several threads sharing the same memory. This lesson is about what happens the instant two of those threads reach into that shared memory at once, using the CPU’s one-instruction-at-a-time steps from The CPU (fetch-decode-execute, the ISA, assembly).