Subj : Re: [.NET] Volatile Fields [correction] To : comp.programming.threads From : Chris Thomasson Date : Mon Sep 19 2005 11:33 am "Cool Guy" wrote in message news:1cgq3c5ccqz6r.dlg@cool.guy.abc.xyz... > David Hopwood wrote: > >> The write to Y is not performed as a single atomic event; it has to be >> modelled >> as two events: "Y = 1 is performed with respect to processor 2" and "Y = >> 1 is >> performed with respect to processor 3". So it can happen that processor 2 >> sees >> Y == 1 before writing Z = 1, but processor 3 does not see Y == 1 until >> after >> it sees Z == 1. > > > > So it's impossible to make such code thread-safe, then? This should do it for x86: Processor 1: Y = 1; L = 1; Processor 2: if (L == 1) { Z = 1; L = 2; } Processor 3: if (L == 2) { assert(Y == 1); } .