Subj : Re: Memory synchronization with pthreads To : comp.programming.threads From : Joseph Seigh Date : Sun Jan 16 2005 06:49 pm On Sun, 16 Jan 2005 23:30:36 +0000, Chris Vine wrote: > Joseph Seigh wrote: >> The phrase "synchronize memory" isn't defined in Posix pthreads. You need >> to learn more about memory models and memory consistency and how it's >> accomplished before you attempt to do memory synchronization outside of >> the >> standard thread design patterns and paradigms. You should learn what >> memory >> barriers are and how to use them. Also why context switching from a >> syscall or thread switch needs to synchronize memory. > > This has been quite enlightening. What do you think the standard in fact > requires when it stipulates that memory must be synchronized between > threads on a fork() call? From what you say, it seems sufficiently > nebulous as to be meaningless (and with respect to other standards would be > regarded as a defect). > fork isn't a pthreads function. It's just another syscall as far as threads go. You end up with a new process with a thread running in a copy of the context of the thread that called fork. No synchronization of memory was done unless you registered an at fork handler with pthread_atfork() AND the handler invoked pthread functions that synchronized memory. Why are you going on about fork()? It creates processes, not threads except for the main thread of the process. -- Joe Seigh .