If I have two or more unrelated processes (not threads, and not forked from a single process) in a multiprocessor environment, can I depend on a futex to provide synchronization ? (the futex would be in shared memory mapped by all the processes) I have not used futexes before, but it seems that the not-contended case is solely in user space.
What should I do to ensure that the writes to shared memory by a process are visible by another process, possibly running on a different processor ?
> If I have two or more unrelated processes (not threads, and not forked > from a single process) in a multiprocessor environment, can I depend > on a futex to provide synchronization ? (the futex would be in shared > memory mapped by all the processes) I have not used futexes before, > but it seems that the not-contended case is solely in user space.
> What should I do to ensure that the writes to shared memory by a > process are visible by another process, possibly running on a > different processor ?
Futex interface shall be used on top of something along the lines of the upcoming std::atomic<> and it's C incarnation ala
> > If I have two or more unrelated processes (not threads, and not forked > > from a single process) in a multiprocessor environment, can I depend > > on a futex to provide synchronization ? (the futex would be in shared > > memory mapped by all the processes) I have not used futexes before, > > but it seems that the not-contended case is solely in user space.
> > What should I do to ensure that the writes to shared memory by a > > process are visible by another process, possibly running on a > > different processor ?
> Futex interface shall be used on top of something along the lines of the > upcoming std::atomic<> and it's C incarnation ala
On Sep 2, 6:56 pm, Avik Ghosh <avik.gh...@gmail.com> wrote:
> If I have two or more unrelated processes (not threads, and not forked > from a single process) in a multiprocessor environment, can I depend > on a futex to provide synchronization ? (the futex would be in shared > memory mapped by all the processes) I have not used futexes before, > but it seems that the not-contended case is solely in user space.
> What should I do to ensure that the writes to shared memory by a > process are visible by another process, possibly running on a > different processor ?
You can, but why not use a portable interface that will use futexes where they're known to work anyway? (Specifically, POSIX process shared mutexes.)
On Sep 5, 12:48 am, David Schwartz <dav...@webmaster.com> wrote:
> On Sep 2, 6:56 pm, Avik Ghosh <avik.gh...@gmail.com> wrote:
> > If I have two or more unrelated processes (not threads, and not forked > > from a single process) in a multiprocessor environment, can I depend > > on a futex to provide synchronization ? (the futex would be in shared > > memory mapped by all the processes) I have not used futexes before, > > but it seems that the not-contended case is solely in user space.
> > What should I do to ensure that the writes to shared memory by a > > process are visible by another process, possibly running on a > > different processor ?
> You can, but why not use a portable interface that will use futexes > where they're known to work anyway? (Specifically, POSIX process > shared mutexes.)
Yes, I think that is what I will do.
So far I have only used pthread_mutex calls in threads (created using pthread_create) where the address space is shared. I now gather that I can use them in dissimilar processes, as long as the pthread_mutex object is created on shared memory.