From owner-freebsd-arch@FreeBSD.ORG Sun Jun 13 00:49:39 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 29B1916A4D0 for ; Sun, 13 Jun 2004 00:49:39 +0000 (GMT) Received: from mail3.speakeasy.net (mail3.speakeasy.net [216.254.0.203]) by mx1.FreeBSD.org (Postfix) with ESMTP id EFD2B43D1F for ; Sun, 13 Jun 2004 00:49:38 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: (qmail 12637 invoked from network); 13 Jun 2004 00:49:19 -0000 Received: from gate.funkthat.com (HELO hydrogen.funkthat.com) ([69.17.45.168]) (envelope-sender ) by mail3.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 13 Jun 2004 00:49:19 -0000 Received: from hydrogen.funkthat.com (jsbapq@localhost.funkthat.com [127.0.0.1])i5D0nJHX035705; Sat, 12 Jun 2004 17:49:19 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.10/8.12.10/Submit) id i5D0nH5I035704; Sat, 12 Jun 2004 17:49:17 -0700 (PDT) Date: Sat, 12 Jun 2004 17:49:17 -0700 From: John-Mark Gurney To: Robert Watson Message-ID: <20040613004917.GC542@funkthat.com> Mail-Followup-To: Robert Watson , Poul-Henning Kamp , arch@freebsd.org, Julian Elischer References: <57800.1086807537@critter.freebsd.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: arch@freebsd.org cc: Poul-Henning Kamp cc: Julian Elischer Subject: Re: reference counting.. continued.. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jun 2004 00:49:39 -0000 Robert Watson wrote this message on Sat, Jun 12, 2004 at 15:33 -0400: > > Our reference counts will almost invariably be integral properties of > > our objects and therefore has to interact with the remaining object > > locking. > > I don't have a strong feeling about the general need for a refcount API, > but I can confirm that many of the interesting objects in the kernel > wouldn't lend themselves to such an API. There are many cases where we'll > want to protect the reference count using an existing lock, in which case > locking built into the reference count API becomes a liability. Socket > reference counting is one example of this: in some ways, it's a general > purpose reference count, but the GC behavior is specific to sockets and > depends on additional uncounted references from file descriptors and the > prototocol layer. In working on locking down KQ, I came across the same problem. What I ended up doing is creating an object that kept a copy of struct mtx * in it. When I created the object, you could either pass in a NULL, and a fresh mutex would be created, or you could pass in your own object's struct mtx *... This makes it more capable of flexibility and only requires a lock/unlocked arg... Just a thought... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."