pthread_rwlock_rdlock hangs

Discussion in 'C++' started by Jaydeep Chovatia, Oct 6, 2011.

  1. Hi,

    In my multi-threaded program I am using "pthread_rwlock_rdlock" to
    lock read/write mutex which is initialized with
    "PTHREAD_MUTEX_ERRORCHECK"
    Under load, call to "pthread_rwlock_rdlock" hangs indefinitely even
    though there are no writers holding the lock. Even after i stop load
    on my program, call is still hung. I tried to take the mutex condition
    when it was locked, please find here:

    (gdb) p m_lock
    $2 = {__data = {__lock = 0, __nr_readers = 1, __readers_wakeup = 60,
    __writer_wakeup = 1230, __nr_readers_queued = 2, __nr_writers_queued =
    48,
    __writer = 0, __pad1 = 0, __pad2 = 0, __pad3 = 0, __flags = 0},
    __size = "\000\000\000\000\001\000\000\000<
    \000\000\000\316\004\000\000\002\000\000\000\060", '\000' <repeats 34
    times>, __align = 4294967296}


    After that I changed my lock from "pthread_rwlock_rdlock" to
    "pthread_rwlock_tryrdlock" and under load this new lock used to return
    EAGAIN sometimes.

    My question is why "pthread_rwlock_rdlock" hangs indefinitely. If
    there are more readers then it should return EAGAIN.

    Any help on this would be appreciated.

    OS Details: Red Hat Enterprise Linux Server release 6.0 (Santiago)
    Linux rwcdtgxb0406 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT
    2010 x86_64 x86_64 x86_64 GNU/Linux

    Thank you,
    Jaydeep
     
    Jaydeep Chovatia, Oct 6, 2011
    #1
    1. Advertising

  2. Jaydeep Chovatia

    Ian Collins Guest

    On 10/ 7/11 08:32 AM, Jaydeep Chovatia wrote:
    >
    > My question is why "pthread_rwlock_rdlock" hangs indefinitely. If
    > there are more readers then it should return EAGAIN.
    >
    > Any help on this would be appreciated.
    >
    > OS Details: Red Hat Enterprise Linux Server release 6.0 (Santiago)
    > Linux rwcdtgxb0406 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT
    > 2010 x86_64 x86_64 x86_64 GNU/Linux


    This isn't a C++ issue, try a Linux group or comp.programming.threads.

    --
    Ian Collins
     
    Ian Collins, Oct 6, 2011
    #2
    1. Advertising

  3. Jaydeep Chovatia

    Adam Skutt Guest

    On Oct 6, 3:32 pm, Jaydeep Chovatia <>
    wrote:
    > Hi,
    >
    > In my multi-threaded program I am using "pthread_rwlock_rdlock" to
    > lock read/write mutex which is initialized with
    > "PTHREAD_MUTEX_ERRORCHECK"
    > Under load, call to "pthread_rwlock_rdlock" hangs indefinitely even
    > though there are no writers holding the lock. Even after i stop load
    > on my program, call is still hung. I tried to take the mutex condition
    > when it was locked, please find here:


    I'm not quite confident about what's going on, since you seem to be
    confusing two separate concurrency structures. But only recursive
    mutexes can be locked more than once by the same thread, so I'm pretty
    confident you're attempting to do something you should not. Error-
    checking mutexes return an error when they are locked twice, you're
    probably not checking for the error correctly.

    A more detailed response is going to require actual code and should
    probably be addressed to a different newsgroup.

    Adam
     
    Adam Skutt, Oct 6, 2011
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mitja Semolic
    Replies:
    0
    Views:
    3,983
    Mitja Semolic
    May 10, 2004
  2. Selden McCabe

    Devenv.exe Hangs on Compile... Why?

    Selden McCabe, Aug 18, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    4,428
    Selden McCabe
    Oct 1, 2004
  3. PaulN

    Pinning Toolbar Hangs VS IDE

    PaulN, Mar 16, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    479
    PaulN
    Mar 22, 2005
  4. Paul A. Rubin

    Re: Cplex hangs in Perl system command

    Paul A. Rubin, Aug 4, 2003, in forum: Perl
    Replies:
    2
    Views:
    3,620
    Paul A. Rubin
    Aug 5, 2003
  5. Tim Shadel

    Gem hangs => TCPSocket.write hangs

    Tim Shadel, Jul 23, 2005, in forum: Ruby
    Replies:
    1
    Views:
    401
    Ville Mattila
    Jul 24, 2005
Loading...

Share This Page