Jim Jones
Jim Jones

Reputation: 2707

Are Posix compliant pthread_mutex_t's from different libraries compatible with each other?

I understand that there are many implementations of pthread_mutex_t, however, I'd like to know if the standard is specific enough that it is possible to share a pthread_mutex_t between different pthread libraries and have it work correctly.

Upvotes: 2

Views: 83

Answers (1)

Florian Weimer
Florian Weimer

Reputation: 33727

No, only if they coordinate for compatibility, and I don't think anyone does.

This can happen even for one C implementation: glibc is incompatible with itself across versions, and the layout for 32-bit and 64-bit versions of the types is different. There is a constraint in the format that existing binaries with their static initializers (PTHREAD_MUTEX_INITIALIZER and its variants) must keep working, but what happens at run time is not fixed, and can change due to bug fixes and optimizations. On the other hand, the static initializer compatibility requirement makes it difficult to fix the 32-bit/64-bit discrepancy, unfortunately.

Upvotes: 2

Related Questions