Date: Wed, 30 Jan 2008 21:42:46 +0100 From: Kris Kennaway <kris@FreeBSD.org> To: John Birrell <jb@FreeBSD.org> Cc: Perforce Change Reviews <perforce@freebsd.org> Subject: Re: PERFORCE change 134244 for review Message-ID: <47A0E146.60905@FreeBSD.org> In-Reply-To: <200801272145.m0RLjSqd053790@repoman.freebsd.org> References: <200801272145.m0RLjSqd053790@repoman.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
John Birrell wrote: > http://perforce.freebsd.org/chv.cgi?CH=134244 > > Change 134244 by jb@jb_freebsd1 on 2008/01/27 21:45:22 > > It seems I need an sx lock to be able to check if it locked. Not sure what you mean by this. All types of locks can check whether they are already held ("locked"). > It's an internal lock here, so the lock consistency is determined > by the code in this file only. > > Specify SX_NOWITNESS to avoid the bogis LOR reports that WITNESS > outputs when internal locks like this are obtained when there > are various other locks already obtained. This lock has no bearing > on the order that other locks are obtained. It is assumed that if you are using an sx lock then your code may sleep while holding it (this is the property that distinguishes sx from rw locks). However, if you sleep while holding a non-sleepable lock (e.g. mutex) then you can deadlock. That is what witness correctly checks for. If you know you will not be sleeping while holding your lock, use an rwlock instead of sx. Kris
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47A0E146.60905>