Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is it possible to share a pthread mutex between two distinct processes?

0
Posted

Is it possible to share a pthread mutex between two distinct processes?

0

> > ie: some way to attach to one like you can attach to shared memory. > > Same question for condition variables. The answer is (as often happens) both YES and NO. Over time, the balance will shift strongly towards YES. The POSIX standard provides an option known commonly as “pshared”, which, if supported on your implementation, allows you to allocate a pthread_mutex_t (or pthread_cond_t) in shared memory, and initialize it using an attributes object with a specific attribute value, such that two processes with access to the shared memory can use the mutex or condition variable for synchronization. Because this is an OPTION in the POSIX standard, not all implementations will provide it, and you cannot safely count on it. However, the Single UNIX Specification, Version 2 (UNIX 98) requires that this POSIX option be supported on any validated UNIX 98 implementation.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123