Previous | Next --- Slide 6 of 37
Back to Lecture Thumbnails
Zarathustra

"no"

msebek

To elaborate on "no", the code that goes into locks is extremely precise, and thought through very carefully to try to prevent ANY interleaving of two, three, four or more that would cause you to lose the Mutual Exclusion aspirations you have to be violated.

All classic theoretical algorithms for locking (e.g. http://en.wikipedia.org/wiki/Peterson's_algorithm) make the 'reasonable assumption' that every thread observed the same world state. If we have multiple cores, each with a different cached worldview, we still need cache coherence (or at least some way to tell the processor to make a little bit of memory coherent for a little while).

skywalker

How this problem is different: The state of the world observed by any thread is not consistent because we are duplicating X. In fact, we do not really have a race condition here either since the threads are writing at different times.

As a result, locks would be useless as well; because actually we're not writing to the same X (but to the duplicated version in the cache, until evicted).