Re: how atomic is the atomic set instruction?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On Fri, Nov 07, 2008 at 04:11:24PM +0100, Ali Günhan Akyürek wrote:
> In kernel code, atomic_set instruction is just "v->counter = i", for the arm
> architectures < v6.
> 
> I couldn't understand how it is atomic. Because, to change a value, two
> seperate instructions needed.(load and store)

A set is atomic - it's a single operation which can't be interrupted.
Either it has happened or it hasn't.

> If an interrupt occurs between them, it is not atomic?

Presumably what you're trying to do is:

	v = atomic_read(something);
	v = some_operation(v);
	atomic_set(something, v);

Just because it's called "atomic" doesn't magically make it atomic - it
can't do.  The above code is no more atomic than:

	v = *something;
	v = some_operation(v);
	*something = v;

The atomicity comes from the operators on the atomic type (atomic_add
etc) not from some random naming.

-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
FAQ:        http://www.arm.linux.org.uk/mailinglists/faq.php
Etiquette:  http://www.arm.linux.org.uk/mailinglists/etiquette.php


[Linux ARM]     [Linux ARM MSM]     [Linux ARM Kernel]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

Add to Google Follow linuxarm on Twitter