*nix System-wide threads and processes mutex *nix System-wide threads and processes mutex unix unix

*nix System-wide threads and processes mutex


Too general of a question, thus a general answer.

The most flexible synchronization facility would probably be POSIX semaphores. There's also old and cumbersome SysV IPC semaphore mechanism, which you might have to use instead depending on platform support.

You might also want to look into PTHREAD lock attributes to see if your platform supports shared semantics.


If the resource is global and shared access is desired, you must use locks. If it is thread-local, use thread-local storage. If it can be local, use a local object.