Changing refcount(9) to use a refcount_t

Ed Schouten ed at 80386.nl
Fri Dec 23 14:08:56 UTC 2011


* John Baldwin <jhb at freebsd.org>, 20111223 14:34:
> Hmm, are we really aiming to replace <machine/atomic.h> with the C1X API
> instead?

That depends on the success and adoption of the API, right? If it turns
out Clang and GCC do a very good job at adopting it properly and in a
timely fashion, why stick to <machine/atomic.h>?

Looking at the specification, it doesn't seem to be that bad. Compared
to what we have in <machine/atomic.h>, it seems to support more
operations (e.g. a regular exchange, instead of our readandclear) and
practically allows any type of barrier for any operation.

> FWIW, I thought about making a refcount_t when first writing <sys/refcount.h> 
> but bde@ talked me out of it.  Bruce is of the general opinion that we should
> avoid adding new *_t typedefs when we can help it.

But in this case there is a valid reason why we should typedef it:
portability. It allows us to implement reference counting any way we
like. Whether it is packing it together with a mutex, using GCC inline
assembly, C1X operations, etc.

I'm not saying we should switch to C1X atomics in the nearby future, but
it wouldn't hurt to make any preparations that allow us to experiment
with it in due time.

-- 
 Ed Schouten <ed at 80386.nl>
 WWW: http://80386.nl/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20111223/bb1dc483/attachment.pgp


More information about the freebsd-fs mailing list