pthread_rwlock_rdlock hangs

  • Thread starter Jaydeep Chovatia
  • Start date
J

Jaydeep Chovatia

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
 
I

Ian Collins

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.
 
A

Adam Skutt

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top