Subject: Re: Atomic ops API
To: Martin Husemann <martin@duskware.de>
From: Andrew Doran <ad@netbsd.org>
List: tech-kern
Date: 03/13/2007 15:49:33
> Maybe add a note that everything besides the cas operations might be
> a lot more expensive than i386-minded people might assume (naively
> ignoring the runtime costs at the hardware bus level)?

Any MP atomic instruction on x86 can cost around 150 cycles on newer
CPUs. They're not cheap there either!

There are usually no special bus cycles involved for atomic operations..
Atomicity is provided by the L1 cache making the line exclusive/modified
and refusing to give it up until the operation completes. The expense is
I think from flushing the pipelines, store buffers, and so on.

Andrew