Previous | Next --- Slide 37 of 66
Back to Lecture Thumbnails
Split_Personality_Computer

All work that is meant to happen atomically must be done all in one block. Here, the programmer has created a race condition on whether thread one's second atomic block (setting B to pointer val) will happen before thread two's atomic block (setting pointer to null). Even if you had a lock on "ptr", the same race condition could occur if you don't set B in the same block.