Re: ZFS committed to the FreeBSD base.
- From: Robert Watson <rwatson@xxxxxxxxxxx>
- Date: Fri, 13 Apr 2007 15:47:52 +0100 (BST)
On Fri, 13 Apr 2007, Craig Boston wrote:
On Fri, Apr 13, 2007 at 05:34:56PM +1000, Bruce Evans wrote:
Doesn't everyone who uses atomic operations knows that they are expensive? :)
Yes, though hopefully they should at least be faster than using a mutex, though for cmpxchg8b it sounds like that may not necessarily be the case...
A common example of this not being the case is statistics updates: it doesn't take too many statistics being updated at once before it makes more sense to use a mutex than individual atomic instructions, as mutex lock and unlock, in the uncontended case, involve an atomic instruction each (with memory barriers). Then it becomes more semantic: is using non-blocking primitives preferable, or are there consistency requirements between "atomically" updated fields? If contention never happens, then maybe you get consistency for free by using a mutex.
As a general rule, unless it's a very clear-cut case (a simple counter), I would encourage people to program with mutexes rather than directly with atomic instructions. It prevents them from having to deal with really weird stuff that happens with weaker memory consistency.
Robert N M Watson
Computer Laboratory
University of Cambridge
_______________________________________________
freebsd-current@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@xxxxxxxxxxx"
- References:
- Re: ZFS committed to the FreeBSD base.
- From: Dag-Erling Smørgrav
- Re: ZFS committed to the FreeBSD base.
- From: Bernd Walter
- Re: ZFS committed to the FreeBSD base.
- From: Dag-Erling Smørgrav
- Re: ZFS committed to the FreeBSD base.
- From: David Schultz
- Re: ZFS committed to the FreeBSD base.
- From: Peter Jeremy
- Re: ZFS committed to the FreeBSD base.
- From: Dag-Erling Smørgrav
- Re: ZFS committed to the FreeBSD base.
- From: Rick C. Petty
- Re: ZFS committed to the FreeBSD base.
- From: Craig Boston
- Re: ZFS committed to the FreeBSD base.
- From: Dag-Erling Smørgrav
- Re: ZFS committed to the FreeBSD base.
- From: Bruce Evans
- Re: ZFS committed to the FreeBSD base.
- From: Craig Boston
- Re: ZFS committed to the FreeBSD base.
- Prev by Date: Re: CFT: new trunk(4)
- Next by Date: [plus 9650SE cards] Re: twa(4) update to support 9550SXU/9590SE controllers
- Previous by thread: Re: ZFS committed to the FreeBSD base.
- Next by thread: Re: ZFS committed to the FreeBSD base.
- Index(es):