From owner-freebsd-arch@FreeBSD.ORG Fri May 21 07:01:46 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 DDBBB16A4D0 for ; Fri, 21 May 2004 07:01:46 -0700 (PDT) Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by mx1.FreeBSD.org (Postfix) with ESMTP id B8D2F43D31 for ; Fri, 21 May 2004 07:01:46 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 2713 invoked from network); 21 May 2004 14:01:35 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 21 May 2004 14:01:35 -0000 Received: from 10.50.40.205 (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.11/8.12.11) with ESMTP id i4LE1Rsp076772; Fri, 21 May 2004 10:01:27 -0400 (EDT) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: freebsd-arch@FreeBSD.org Date: Fri, 21 May 2004 10:02:02 -0400 User-Agent: KMail/1.6 References: In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200405211002.02386.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on server.baldwin.cx cc: arch@FreeBSD.org cc: Julian Elischer Subject: Re: atomic reference counting primatives. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2004 14:01:47 -0000 On Thursday 20 May 2004 04:56 pm, Julian Elischer wrote: > This has been raised before but I've come across uses for it again and > again so I'm raising it again. > JHB once posted some atomic referenc counting primatives. (Do you still > have them John?) > Alfred once said he had soem somewhere too, and other s have commentted > on this before, but we still don't seem to have any. I still have them. Part of the problem is that there are lots of different reference counts that work in different ways, and if you try to come up with a single all-singing, all-dancing ref count implementation it will be too complicated to provide any benefit. What I do think might be useful might be a simple refcount() API that is useful for objects that are immutable when the refcount > 1 like ucred and are updated via COW. These type of objects have a mutex that just protects a refcount and nothing else. Using a single refcount op for those objects will cut the number of atomic ops in half. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org