From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 3 17:26:39 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A781716A440 for ; Wed, 3 Aug 2005 17:26:39 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: from mv.twc.weather.com (mv.twc.weather.com [65.212.71.225]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4996143D45 for ; Wed, 3 Aug 2005 17:26:39 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: from [10.50.40.201] (Not Verified[65.202.103.25]) by mv.twc.weather.com with NetIQ MailMarshal (v6, 0, 3, 8) id ; Wed, 03 Aug 2005 13:41:16 -0400 From: John Baldwin To: freebsd-hackers@freebsd.org, hselasky@c2i.net Date: Wed, 3 Aug 2005 13:21:31 -0400 User-Agent: KMail/1.8 References: <200508030023.04748.hselasky@c2i.net> In-Reply-To: <200508030023.04748.hselasky@c2i.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200508031321.32276.jhb@FreeBSD.org> Cc: Subject: Re: How to do proper locking X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Aug 2005 17:26:39 -0000 On Tuesday 02 August 2005 06:23 pm, Hans Petter Selasky wrote: > Hi, > > I am looking for a safe way to access structures that can be freed. The > solution I am looking for must not: > > - hinder scaleability > - lead to use of a single lock > - lead to lock order reversal These aren't a very clear set of requirements. Note that you can't hold a lock across malloc(), so your allocation code isn't safe. You can try taking at look at some existing refcounted structures such as ucreds, p_args, etc. or looking at structures held in a global list like proc. What actual problem are you trying to solve? How does code obtain references to my_struct objects? Are they hung off another object that has a lock? Are they in a global list? -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org