From owner-freebsd-arch Thu Sep 28 11: 7:29 2000 Delivered-To: freebsd-arch@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 0D7C837B622 for ; Thu, 28 Sep 2000 11:06:38 -0700 (PDT) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id e8SI6bI02119 for arch@freebsd.org; Thu, 28 Sep 2000 11:06:37 -0700 (PDT) Date: Thu, 28 Sep 2000 11:06:37 -0700 From: Alfred Perlstein To: arch@freebsd.org Subject: we need atomic_t Message-ID: <20000928110637.U7553@fw.wintelcom.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.4i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Linux has a datatype called "atomic_t", very useful for refcounts and struct counters like tcpstat. My impression is that it's the largest type an arch can support atomic ops on without weird gyrations and/or extremely expensive operations. Example: atomic_t is 32bit on i386, and I think 24 on sparc32. This would replace our atomic_op_type with just atomic_op and make code easier to read and get right. Linux also has the ability to do a atomic_dec_and_test() which returns whether the operation decremented the atomic_t down to 0 or not very useful for making sure _you_ were the one that made the refcount == 0 so that you can free it. I'm already seeing a pretty good examples of where this can be applied: 1) struct ucred->cr_ref 2) struct uidinfo->ui_ref 3) tcpstats 4) other stats :) 5) mbuf external ref counts I don't have the gcc-assembler-foo to do this optimally without directly copying from Linux which isn't acceptable. Can anyone snap this up? I'd really appreciate it. thanks, -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] "I have the heart of a child; I keep it in a jar on my desk." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message