[LAD] Atomic Operations

fons at kokkinizita.net fons at kokkinizita.net
Mon Dec 14 21:54:15 UTC 2009


On Mon, Dec 14, 2009 at 02:45:38PM -0500, Stephen Sinclair wrote:

> I didn't read the others, but I looked at this one and I think it's
> important to point out some problems with it.  He is claiming that you
> cannot increment an integer atomically, which is true, but this
> doesn't mean that the reads and writes, by themselves, are not atomic
> operations.

True. OTOH having devoted cq. wasted part of my life
programming SPARC machines I can confirm Paul Davis'
comment on those: sig_atomic_t on these machines was
24 bits. But I *never* understood how on earth they
managed to create this anomaly on what was after all
a full 32-bit architecture.

A simple pattern I use to avoid the incr/decr problem
is to use two variables, each one of them being modified
(incremented) by only one thread. Instead of testing for
zero test for equality. 

Ciao,

-- 
FA



More information about the Linux-audio-dev mailing list