sharing mutexes

Brooks Davis brooks at
Mon Aug 30 01:09:31 PDT 2004

On Mon, Aug 30, 2004 at 10:48:11AM +0300, Petri Helenius wrote:
> Brooks Davis wrote:
> >That depends on what you mean.  You can use sysv semaphores between
> >processes, but their API is problematic in some applications.
> >
> >Could you explain what you want to do in more detail?
> > 
> I have multiple processes running threaded applications which would like 
> to do 64bit wide atomic arithmetic, which if I understand correctly can 
> only be achieved either via IPC (having a master process to do all the 
> stuff) or sharing a mutex somehow. And as far as I understand, mutexes 
> are process-local by default.

If you actully have a multi-process, multi-threaded application doing
writes to shared memory, they you probably need to use sysv semaphores
at this point since I think that's our only only portable, multi-process
locking mechanism at this point.  The code for POSIX sempahores seems to
indicate that you can use them in multiple processes if they are created
before a fork, but I've never tried that.  If you have a multi-threaded
application which is not multi-process, sysv semaphores or posix
semaphores will work.

-- Brooks

Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url :

More information about the freebsd-threads mailing list