On Fri, Jun 02, 2006 at 05:50:21AM +0100, Ricardo Correia wrote:
> On Friday 02 June 2006 05:12, Neil Perrin wrote:
> > I believe RW_LOCK_HELD checks it's not held by the calling thread only.
> > Note, a thread should not doubly read lock the same lock as
> > a write lock from another thread between the 2 would deadlock.
> 
> Ok, that makes sense. Thanks :)
> 
> I'm assuming RW_WRITE_HELD() and MUTEX_HELD() also only checks if it's held 
> by 
> the calling thread (I couldn't find any documentation on this, and the 
> implementation of the RW_xxx_HELD() macros weren't very easy to 
> understand :p)

Our userland threads library keeps track, of which reader locks are held by
a given thread.  If you look at the implementation of _rw_read_held():

http://cvs.opensolaris.org/source/xref/on/usr/src/lib/libc/port/threads/rwlock.c#_rw_read_held

it checks the current thread's list of locks to verify that it is not being
held.

> Oh well... now I only have to figure out a way to emulate this with POSIX 
> threads.. :)

It's much easier with help from the implementation;  you could just disable
that single assert.

Cheers,
- jonathan

-- 
Jonathan Adams, Solaris Kernel Development

Reply via email to