mystikos icon indicating copy to clipboard operation
mystikos copied to clipboard

Support glibc static rwlock initializers

Open mikbras opened this issue 3 years ago • 1 comments

Recently PR #355 was merged to support glibc static mutex initializers (in the case where the program was compiled with glibc headers). An review of the pthread-related initializers reveals that read-write locks have a similar problem. In particular, the following should be supported.

PTHREAD_RWLOCK_INITIALIZER
PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP

mikbras avatar May 12 '21 18:05 mikbras

Updates:

Musl libc does not currently support non-recursive read-write locks.

Also, PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP is placed in an unused word in pthread_rwlock_t and is ignored, which means the writer will always be recursive (i.e., the write thread will not block if it takes a write lock a second time). It is not clear whether this poses a problem or not. Rather than hanging (as with recursive mutexes before the fix), the program will fail to hang.

mikbras avatar May 12 '21 19:05 mikbras