[omniORB] omniORB, posix rwlock_t and deadlock
Attila Pletyak
attila.pletyak@anemo.com
Tue, 12 Jun 2001 14:38:38 +0200
--------------030307040507050500030009
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii; format=flowed
Dmitry Mityugov wrote:
>Just a shot in the dark.
>
>> There is a wrapper class around the pthread_rwlock_t types, so they
>>get unlocked in every case.
>>
>
>Have you defined a copy constructor and assignment operator for this class?
>
It looks like this:
class ReadWriteLock {
pthread_rwlock_t &mutex;
public:
enum LockType{
READLOCK,
WRITELOCK
};
ReadWriteLock (pthread_rwlock_t &m, LockType lt)
: mutex (m)
{
switch (lt)
{
case READLOCK:
default:
pthread_rwlock_rdlock (&mutex);
break;
case WRITELOCK:
pthread_rwlock_wrlock (&mutex);
break;
}
}
~ReadWriteLock()
{
pthread_rwlock_unlock (&mutex);
}
};
Every servant has an own pthread_rwlock_t member, which is initialized
in its constructor, and before accessing the shared memory, there is a
ReadWriteLock currentRead( servantRWMember, ReadWriteLock::READLOCK );
Maybe my terminology is not correct as this is a helper class.
Attila Pletyak
>
>Dmitry
>
>
>
--------------030307040507050500030009
Content-Transfer-Encoding: 7bit
Content-Type: text/html; charset=us-ascii
<html><head></head><body><br>
<br>
Dmitry Mityugov wrote:<br>
<blockquote type="cite" cite="mid:008301c0f33b$2e9bb3f0$0100000a@ddhome"><pre wrap="">Just a shot in the dark.<br><br></pre>
<blockquote type="cite"><pre wrap=""> There is a wrapper class around the pthread_rwlock_t types, so they <br>get unlocked in every case.<br></pre></blockquote>
<pre wrap=""><!----><br>Have you defined a copy constructor and assignment operator for this class?<br></pre>
</blockquote>
It looks like this:<br>
<br>
class ReadWriteLock {<br>
pthread_rwlock_t &mutex;<br>
<br>
public:<br>
enum LockType{<br>
READLOCK,<br>
WRITELOCK<br>
};<br>
<br>
ReadWriteLock (pthread_rwlock_t &m, LockType lt)<br>
: mutex (m)<br>
{<br>
<br>
switch (lt)<br>
{<br>
case READLOCK: <br>
default:<br>
pthread_rwlock_rdlock (&mutex);<br>
break;<br>
case WRITELOCK:<br>
pthread_rwlock_wrlock (&mutex);<br>
break;<br>
}<br>
<br>
}<br>
<br>
~ReadWriteLock()<br>
{<br>
pthread_rwlock_unlock (&mutex);<br>
}<br>
};<br>
<br>
Every servant has an own pthread_rwlock_t member, which is initialized in
its constructor, and before accessing the shared memory, there is a <br>
ReadWriteLock currentRead( servantRWMember, ReadWriteLock::READLOCK );<br>
<br>
Maybe my terminology is not correct as this is a helper class.<br>
<br>
Attila Pletyak<br>
<blockquote type="cite" cite="mid:008301c0f33b$2e9bb3f0$0100000a@ddhome"><pre wrap=""><br>Dmitry<br><br><br><br></pre>
</blockquote>
<br>
</body></html>
--------------030307040507050500030009--