This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Does the implementation of pthread rwlock obey POSIX specification?
- From: Neil <freeordie dot k at gmail dot com>
- To: libc-help at sourceware dot org
- Date: Tue, 27 Dec 2011 11:08:17 +0800
- Subject: Does the implementation of pthread rwlock obey POSIX specification?
- References: <CAM-JBkGCtWWUkBunxnQEPX4jjF-OP8AP=aEtT9O_Q5HAkTvsug@mail.gmail.com>
Hi All,
I am testing POSIX on project Yocto with POSIX suite from ltp site:
http://ltp.git.sourceforge.net/git/gitweb.cgi?p=ltp/ltp.git;a=tree;f=testcases/open_posix_testsuite;h=2ef1a9c3eca086d06f3ed2061c32c610c44a78da;hb=HEAD
When run the test test case
open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c
http://ltp.git.sourceforge.net/git/gitweb.cgi?p=ltp/ltp.git;a=blob_plain;f=testcashttp://ltp.git.sourceforge.net/git/gitweb.cgi?p=ltp/ltp.git;a=blob_plain;f=testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c;hb=HEADes/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c;hb=HEAD
it fails. Test steps are as follow:
1. Main thread set its shcedule policy as "SCHED_FIFO", with highest
priority: sched_get_priority_min()+2.
2. Main thread read lock 'rwlock'
3. Create a writer thread, with schedule policy as "SCHED_FIFO", and
priority using sched_get_priority_min()+1.
4. The thread write lock 'rwlock', should block.
5. Main thread create a reader thread, with schedule policy as
"SCHED_FIFO", and priority sched_get_priority_min()
6. Reader thread read lock 'rwlock', should block, since there is a
higher priority writer blocked on 'rwlock'
But the reader thread doesn't block. Because in POSIX specification
or pthread_rwlock_rdlock() manual page says:
 If the Thread Execution Scheduling option is supported, and
the threads involved in the lock are executing
ÂÂÂÂÂÂ with the scheduling policies SCHED_FIFO or SCHED_RR, the
calling thread shall not acquire the lock if a
ÂÂÂÂÂÂ writer holds the lock or if writers of higher or equal priority
are blocked on the lock; otherwise, the callâ
ÂÂÂÂÂÂ ing thread shall acquire the lock.
So it seems the implementation of pthread rwlock doesn't obey the
POSIX specification, right? If so, if there is a plan to
make eglibc rwlock obey the POSIX specification?
I notice that there is a flag in pthread_rwlock_t to spec prefer read
lock or right lock, but it doesn't care the priorities.
Any reply is appreciate.
--
Regards,
Neil