public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/10180] New: Write locks shall take precedence over read locks by default
@ 2009-05-21  7:20 zhangxiliang at cn dot fujitsu dot com
  2009-05-21 13:56 ` [Bug nptl/10180] " drepper at redhat dot com
  0 siblings, 1 reply; 2+ messages in thread
From: zhangxiliang at cn dot fujitsu dot com @ 2009-05-21  7:20 UTC (permalink / raw)
  To: glibc-bugs

I tested the scheduler of rwlock, and found that when write lock is blocked
(a read process has acquired read lock), the other read process can acquired
read lock again.

A read process                       <--acquired read lock
  ->A write process                  <--block for the reading process unlock
    ->The other read process         <--it acquired read lock again
      ->The write process            <--block for the two reading process unlock

If an application has many read process, the write process may be blocked at 
all 
times.

In pthread_rwlock_rdlock() manual, the other read process should be blocked 
when 
a write process blocked. Write locks shall take precedence over read locks by
default.

Signed-off-by: Zhang Xiliang <zhangxiliang@cn.fujitsu.com>
---
 nptl/pthread_rwlock_init.c     |    2 +-
 nptl/sysdeps/pthread/pthread.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/nptl/pthread_rwlock_init.c b/nptl/pthread_rwlock_init.c
index 27f25ac..7bc723b 100644
--- a/nptl/pthread_rwlock_init.c
+++ b/nptl/pthread_rwlock_init.c
@@ -46,7 +46,7 @@ __pthread_rwlock_init (rwlock, attr)
   rwlock->__data.__writer = 0;
 
   rwlock->__data.__flags
-    = iattr->lockkind == PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP;
+    = iattr->lockkind != PTHREAD_RWLOCK_PREFER_READER_NP;
 
   /* The __SHARED field is computed to minimize the work that needs to
      be done while handling the futex.  There are two inputs: the
diff --git a/nptl/sysdeps/pthread/pthread.h b/nptl/sysdeps/pthread/pthread.h
index cc7472e..91ab49c 100644
--- a/nptl/sysdeps/pthread/pthread.h
+++ b/nptl/sysdeps/pthread/pthread.h
@@ -117,7 +117,7 @@ enum
   PTHREAD_RWLOCK_PREFER_READER_NP,
   PTHREAD_RWLOCK_PREFER_WRITER_NP,
   PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
-  PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP
+  PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_WRITER_NP
 };
 
 /* Read-write lock initializers.  */

-- 
           Summary: Write locks shall take precedence over read locks by
                    default
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
        AssignedTo: drepper at redhat dot com
        ReportedBy: zhangxiliang at cn dot fujitsu dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=10180

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug nptl/10180] Write locks shall take precedence over read locks by default
  2009-05-21  7:20 [Bug nptl/10180] New: Write locks shall take precedence over read locks by default zhangxiliang at cn dot fujitsu dot com
@ 2009-05-21 13:56 ` drepper at redhat dot com
  0 siblings, 0 replies; 2+ messages in thread
From: drepper at redhat dot com @ 2009-05-21 13:56 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2009-05-21 13:56 -------
(In reply to comment #0)
> If an application has many read process, the write process may be blocked at 
> all 
> times.

Then this is an application bug.  It has to explicitly request the behavior it
depends on.  There will be no change.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


http://sourceware.org/bugzilla/show_bug.cgi?id=10180

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-05-21 13:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-21  7:20 [Bug nptl/10180] New: Write locks shall take precedence over read locks by default zhangxiliang at cn dot fujitsu dot com
2009-05-21 13:56 ` [Bug nptl/10180] " drepper at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).