Question about pthread_process_shared attribute



For interprocess synchronization mutexes, it seems some
implementations of posix threads support a PTHREAD_PROCESS_SHARED
flag, which can be used so that a mutex can work between processes,
rather than only between threads.

I have two questions about this:

1: In order for inter-process synchronization to work, does the
pthread_mutex_t object need to be placed in shared memory?

2: What is the advantage/difference between using a shared mutex and
using posix semaphores. (Note, I'm not asking about System V
semaphores, which are annoying to use, but rather posix semaphores,
i.e. semaphores which use the sem_wait/sem_post system calls)

Thanks.

.



Relevant Pages

  • Re: thread mutexes
    ... I would like, if possible, someone to explain to me POSIX threads? ... In particular, the mutex lock/unlock functions. ... exactly they lock. ... You as the programmer establish a convention: ...
    (comp.unix.programmer)
  • Re: pthread_mutex is not released when process closes
    ... or hidden in the kernel and no way accessable from user-space. ... (Or else the mutex itself might get trashed, and all bets are kinda off.) ... like that be standard conforming wrt fully supporting the robust attribute? ... There's no explicit POSIX rule that robust mutexes not be susceptible to user-mode corruption. ...
    (comp.programming.threads)
  • Re: Pthread programming: about the lost condition signals.
    ... In POSIX, ... threads blocked on the condition variable *IS* protected by the mutex. ... The `list of threads' is always belongs to the data structure of the ... It is an error because he uses a structure member to protect the ...
    (comp.programming.threads)
  • Re: Interesting GCC optimization, but is it legal if POSIX thread support is claimed?
    ... mutex is invalid according to POSIX. ... Without the optimization, it doesn't. ... Or, to put it another way, if a POSIX-compliant compiler may add: ... That is -- if POSIX ...
    (comp.programming.threads)
  • Re: when multiple threads are waiting on a mutex, which one will acquire the lock first?
    ... My question is, when the thread that held the mutex release it, is it ... which ones are actually waiting. ... You're confusing forward progress guarantees, which Posix does not have, ...
    (comp.programming.threads)