←back to thread

517 points bkolobara | 1 comments | | HN request time: 0.343s | source
Show context
antirez ◴[] No.45043093[source]
I always thought that the POSIX threads semantics that forces the thread acquiring the lock to be the same thread that releases it, is too strict and not needed. In certain use cases it forces you to redesign the code in more complicated ways.
replies(2): >>45043255 #>>45050351 #
1. murderfs ◴[] No.45043255[source]
It isn't too strict. Releasing a pthread_mutex has the semantics of being a release memory barrier, which means that any writes on that thread will be visible by other threads that issue a subsequent acquire memory barrier (e.g. by acquiring the mutex).

If you want this behavior, it's relatively simple to implement your own mutex on top of futex, but no one is going to expect the behavior it provides.