This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Concurrency semantics of fork


On 11/10/2015 01:10 PM, Adhemerval Zanella wrote:
> I am still trying to figure the issue you are raising: although COW does 
> implicit sharing, my understanding is the pages are still independent
> regarding memory semantic.  It should not stop memory reordering regarding
> any other process that might sharing the pages.

Assume that a thread does this:

unsigned a, b;

unsigned offset = rand ();
lock ();
a -= offset;
b += offset;
unlock ();

The process calls fork in another thread.  In the child process, we peek
at the implementation of the lock (let's assume it's futex-based), and
we determine, based on the lock value, that the lock has not been
acquired.  Looking at a and b, do we always observe that a + b == 0?
(Obviously, if the lock looks as if it has been acquired, all bets are off.)

Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]