On Tue, 9 Oct 2007, Roy Lyseng wrote:

Are increments atomic across SMP/multicore? It'd be hard to corrupt it, but I don't know off the top of my head if it's safe to ignore locking when you're just reading/writing to one set of 4-8bytes. I'll have to read up (or hope someone who knows better about this use of memory barriers chimes in. It's not something I deal with much outside of tracking down kernel bugs on SMP systems).

Increments are generally not atomic. You have interfaces like atomic_inc_ulong() in Solaris 10 and in the Linux kernel (AFAIK).

In Linux there's /usr/include/asm/atomic.h which has:

void atomic_inc(atomic_t *v)

Not sure if it's supported on every last platform, though.

-Todd

Reply via email to