Information Technology Reference
In-Depth Information
Concurrent Program
Shared Objects
e.g., bounded buffer
barber chair
Synchronization Objects
e.g., lock
condition variable
Atomic Read−Modify−Write
Instructions
e.g., test−and−set
disable interrupts
Figure5.2: Multi-threaded programs are built with shared objects, shared
objects are built using synchronization objects, and synchronization objects are
implemented using atomic read-modify-write instructions.
Synchronization variables coordinate access to state variables, which are
Definition: state variables
just the normal member variables of an object that you are familiar with
from single-threaded programming (e.g., integers, strings, arrays, pointers,
etc.)
Using synchronization variables simplifies implementing shared objects.
In fact, not only do shared objects externally appear quite similar to
traditional single-threaded objects, by implementing them with synchro-
nization variables, we can also make their internal implementations quite
similar to what you are used to from implementing single-threaded pro-
grams.
Atomic read-modify-write instructions. Although the layers above
benefit from a simpler programming model, it is not turtles all the way
down. Internally, synchronization variables must manage the interleavings
of dierent threads' actions.
Rather than implementing synchronization variables such as locks and
condition variables using only atomic loads and stores as we attempted
to do for the Too Much Milk problem, modern implementations build
synchronization variables using atomic read-modify-write instructions . An
Definition: atomic
read-modify-write
instructions
atomic read-modify-write instruction allows one thread to have exclusive
access a memory location while the instruction's read, modication, and
write of that location are guaranteed not to be interleaved with any other
thread's access to that memory.
Search WWH ::




Custom Search