Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Sep 2000 11:06:37 -0700
From:      Alfred Perlstein <bright@wintelcom.net>
To:        arch@freebsd.org
Subject:   we need atomic_t
Message-ID:  <20000928110637.U7553@fw.wintelcom.net>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000928110637.U7553>