Subject: Re: Atomic operations for NetBSD
To: Tonnerre <tonnerre@thundrix.ch>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 06/11/2005 11:13:08
On Sat, Jun 11, 2005 at 01:58:38AM +0200, Tonnerre wrote:
> Salut,
> 
> The following patch implements atomic operations for NetBSD, but only
> for i386, alpha, and PowerPC based architectures. The generic way for
> architectures that don't support to execute those functions in an atomic
> fashion would be to lock, execute the functions, and unlock. Sure, this
> sucks, but well.

Actually I suspect that the code fragments you showed are all just as
expensive as using a lock - you are just using the data item itself
as the lock.

If you want to avoid the lock you need to either:

For statistics is may be enough to just ignore the fact that counts
get missed occaisionally.

Otherwise use per-cpu counters (in different cache lines) and sum them
when the value is wanted - after all it will be out of date by the
time it is used anyway...

	David

-- 
David Laight: david@l8s.co.uk