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.

Passing ownership of a mutex?

mutex ownership passing
0
Posted

Passing ownership of a mutex?

0

[See the code example for FIFO Mutexes on this web page. They *may* do what you want. -Bil “Fred A. Kulack” wrote: > You can’t portably unlock a mutex in one thread that was locked by another > thread. Fred’s absolutely correct, but, as this is a common problem, I’d like to expand and stress this warning. The principal attribute of a mutex is “exclusive ownership”. A locked mutex is OWNED by the thread that locked it. To attempt to unlock that mutex from another thread is not merely “nonportable” — it is a severe violation of POSIX semantics. Even if it appears to work on some platforms, it does not work. You may not be getting correct memory visibility, for example, on SMP RISC systems. While POSIX does not require that any implementation maintain the ID of the owning thread, any implementation may do so, and may check for and report the optional POSIX errors for illegal use of the mutex. The Single UNIX Specification, Version 2 (SUSV2, or UNIX98), adds support for various “types” of

Related Questions

What is your question?

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

Experts123