
5.5 Synchronization 339
to return whether the atomic sequence was executed successfully or not. One way to
provide this atomicity for user processes is to place the lock routine in the operating
system and access it through a system call, but this is expensive and leaves the ques-
tion of how the locks are supported by the operating system
itself.
Another option is
to utilize a hardware lock around the instruction sequence for the lock routine, but
this requires hardware locks and tends to be slow on modern processors.
An efficient, general-purpose solution to the lock problem is to support an atomic
read-modify-write instruction in the processor' ...