From owner-p4-projects@FreeBSD.ORG Wed Jan 30 20:42:48 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5C77E16A46E; Wed, 30 Jan 2008 20:42:48 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F18C116A41A; Wed, 30 Jan 2008 20:42:47 +0000 (UTC) (envelope-from kris@FreeBSD.org) Received: from weak.local (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 48EBD13C47E; Wed, 30 Jan 2008 20:42:47 +0000 (UTC) (envelope-from kris@FreeBSD.org) Message-ID: <47A0E146.60905@FreeBSD.org> Date: Wed, 30 Jan 2008 21:42:46 +0100 From: Kris Kennaway User-Agent: Thunderbird 2.0.0.9 (Macintosh/20071031) MIME-Version: 1.0 To: John Birrell References: <200801272145.m0RLjSqd053790@repoman.freebsd.org> In-Reply-To: <200801272145.m0RLjSqd053790@repoman.freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Perforce Change Reviews Subject: Re: PERFORCE change 134244 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jan 2008 20:42:48 -0000 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