Question about Thread Execution Scheduling of pthread rwlock

Neil freeordie.k@gmail.com
Mon Apr 16 01:39:00 GMT 2012


Hi,

Could anyone give some comments about it? Thanks.

On the POSIX spec pthread_rwlock_rdlock() section about tps:

---------------------------------------------------
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 calling thread shall acquire the lock.
----------------------------------------------------

But the glibc/eglibc's implement doesn't care the the priority, and
just provides a rwlock->__data.__flags flag to
identify perfer 'read lock' or write lock.

By default when a rwlock has read locked on a critical region, then a
rwlock trys to write locked on the critical region
then it will be blocked. At this time another rwlock try to read lock
the region it will get the critical region.
So this breaks the POSIX spec.

Why does glibc/eglibc deal rwlock in this way? Does that because they
don't support "Thread Execution Scheduling option"?
Thanks.

-- 
Regards,
Neil



More information about the Libc-help mailing list