Subj : Re: posix and lock-free algorithms To : comp.programming.threads From : David Hopwood Date : Fri Aug 12 2005 03:48 am David Schwartz wrote: > "David Hopwood" wrote: >>Alexander Terekhov wrote: >>>David Schwartz wrote: >>>[...] >>> >>>> Why not? POSIX defines the mutex functions as sychronizing memory. >>> >>>https://www.opengroup.org/austin/mailarchives/ag/msg07705.html >> >>And https://www.opengroup.org/austin/mailarchives/ag/msg07699.html > > If there are no global memory barriers, it is impossible to synchronize > memory. Wrong. Let's look again at the precise wording: Applications shall ensure that access to any memory location by more than one thread of control (threads or processes) is restricted such that no thread of control can read or modify a memory location while another thread of control may be modifying it. This is the relevant 'no data races' requirement on applications. Such access is restricted using functions that synchronize thread execution and also synchronize memory with respect to other threads. The following functions synchronize memory with respect to other threads: [blah] This is giving a way (perhaps the only way; that's not particularly clear) of satisfying the requirement. In context, it *is* clear that whatever "synchronizing memory" means, it must mean something that can be used to avoid reading or modifying a memory location (that is, *each* memory location that could potentially be accessed from more than one thread) while another thread of control may be modifying it. But that doesn't have to be a global memory barrier -- because there patently are other ways to satisfy the requirement that only involve constraints on ordering of accesses to particular subsets of locations, not global constraints. There's nothing here to say that a global memory barrier even has to be implementable, or well-defined, on the target architecture. > POSIX requires the mutex function to "synchronize memory". There are > no caveats or warning words in this, so it *must* mean to fully synchronize > all of memory. You're imagining things :-) > You cannot say "I synchronize memory because I partially synchronize > some of the memory". Does it say "all memory"? No, it doesn't. And my interpretation is supported by the fact that you don't need to synchronize all of memory in order to meet the 'no data races' requirement. -- David Hopwood .