Subj : Re: an interesting threading-question To : comp.programming.threads From : David Schwartz Date : Wed Sep 14 2005 06:09 pm "Oliver S." wrote in message news:4328ab5d$0$2111$9b4e6d93@newsread2.arcor-online.net... > I've got a question regarding threading with C/C++: > When I call a function which is out of scope for the compiler turn > (f.e. in another module without global optimization or a OS-function), > the compiler would have to flush all preceding writes and execute all > preceding reads to non-local variables (and local variables which have > been passed as references to "unknown" functions as well) to ensure > that these variables can be seen by the called function and that pre- > ceding reads wouldn't read data which could have been changed by the > called function - and this is usually done by a combined read/write > -barrier (and this is the same for following reads/writes and thus, > explicit barriers are often not necessary). But this is only necessary > for the executing thread to become self-consistent and not to become > consistent with other threads. So theroretically this barriers could > affect only the self-consitency and there could be further mechanisms > which would help to become globally consistent. So soes anyone know > an architecture which has two consistency-levels on account of this? Even x86 is like this. Memory barriers are not needed for calls within a single thread because out of order writes and speculative fetches don't cause problems for a single thread running in a single processor. DS .