<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; ">Hi,</div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; ">In my multi-threaded program I am using "<b>pthread_rwlock_rdlock</b>" to lock read/write mutex which is initialized with "<b>PTHREAD_MUTEX_ERRORCHECK</b>" </div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; ">Under load, call to "<b>pthread_rwlock_rdlock</b>" 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:</div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; "><br></div><div><div><font
 class="Apple-style-span" face="arial, helvetica, sans-serif" color="#0000bf">(gdb) p m_lock</font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif" color="#0000bf">$2 = {__data = {__lock = 0, __nr_readers = 1, __readers_wakeup = 60, __writer_wakeup = 1230, __nr_readers_queued = 2, __nr_writers_queued = 48,</font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif" color="#0000bf">    </font><font class="Apple-style-span" face="arial, helvetica, sans-serif" color="#bf005f"><b>__writer</b></font><font class="Apple-style-span" face="arial, helvetica, sans-serif" color="#0000bf"> = 0, __pad1 = 0, __pad2 = 0, __pad3 = 0, __flags = 0},</font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif" color="#0000bf">  __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}</font></div></div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; ">After that I changed my lock from "<b>pthread_rwlock_rdlock</b>" to "<b>pthread_rwlock_<span class="Apple-style-span" style="background-color: rgb(253, 238, 224);"><font class="Apple-style-span" color="#bf00bf">try</font></span>rdlock</b>" and under load this new lock used to return EAGAIN sometimes. </div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; ">My question is why "<b>pthread_rwlock_rdlock</b>" hangs indefinitely. If there are more readers then it should return EAGAIN.</div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;
 "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; ">Any help on this would be appreciated.<br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; "><b>OS Details:</b> <b><font class="Apple-style-span" color="#007f40">Red Hat Enterprise Linux Server release 6.0 (Santiago)</font></b></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif" color="#007f40">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</font><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; "><br></div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; ">Thank you,</div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; ">Jaydeep</div></div></body></html>