The Wish For Atomicity

In this lesson, you will see how the race conditions can be eliminated by the atomicity of the instructions.

We'll cover the following...

In the last lesson, we discussed the problem of the race condition in threads accessing shared data. Let’s look at a possible solution to this problem.

TIP: USE ATOMIC OPERATIONS

Atomic operations are one of the most powerful underlying techniques in building computer systems, from the computer architecture, to concurrent code (what you are studying here), to file systems (which you’ll study soon enough), database management systems, and even distributed systems“Atomic Transactions” by Nancy Lynch, Michael Merritt, William Weihl, Alan Fekete. Morgan Kaufmann, August 1993. A nice text on some of the theory and practice of atomic transactions for distributed systems. Perhaps a bit formal for some, but lots of good material is found herein.

The idea behind making a series of actions atomic is simply expressed with the phrase “all or nothing”; it should either appear as if all of the actions you wish to group ...