Re: atomic_t vs. volatile?

From: Manfred Spraul (manfreds@colorfullife.com)
Date: Sun May 14 2000 - 13:44:12 EST


Jeff Garzik wrote:
>
>
> Is marking these two variables "volatile" sufficient for atomicity? Or
> is atomic_t needed?
>

cur_tx is a counter:
volatile is not enough, unless you have external synchronization, you
need atomic_t.

But:
* atomic_t doesn't solve all problems:

        val = atomic_read(&atomic_pos);
        atomic_inc(&atomic_pos);

is unsafe. [but hard_start_xmit is synchronized on xmit_lock, so 8139too
looks good ;)]

* the atomic operations [atomic_inc, atomic_set_mask,...] are really
expensive.
On i386 SMP, the break even point for a spinlock should be 1-3
atomic_inc calls. 2-5 calls for an irqsave spinlock.

--
	Manfred

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:24 EST