Subject: Re: Atomic operations for NetBSD
To: None <tech-kern@NetBSD.org>
From: Joerg Sonnenberger <joerg@britannica.bec.de>
List: tech-kern
Date: 06/12/2005 18:46:59
On Sat, Jun 11, 2005 at 11:13:08AM +0100, David Laight wrote:
> 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.

Depends on which costs you are measuring. It has the advantage of
being non-blocking (read: one thread always advances and e.g. an ISR
can't block the access). Speaking about bus time, if all you need is
ONE atomic update, it is faster, since a mutex normally needs TWO
atomic operations (lock + unlock).

Joerg