
94 CHAPTER 4. SHARED MEMORY: R
shared-memory paradigm doesn’t scale well (Section 2.9), but the advent
of modern multicore systems, especially GPUs, has done much to counter
that argument.
4.6 Locks and Barriers
These are two central concepts in shared-memory programming. To explain
them, we begin with the concept of race conditions.
4.6.1 Race Conditions and Critical Sections
Consider software to manage online airline reservations, and for simplicity,
assume there is no overbooking of seats. At some point in the program,
there will be a section consisting of one or more lines of code whose purpose
is to perform the actual reservation of a seat. The