atomic operations in user space

2 messages, 2 authors, 2006-08-22 · open the first message on its own page

atomic operations in user space

From: Xupei Liang <hidden>
Date: 2006-08-22 20:57:06

Hi,

On the PPC platform, can I use the atomic operations
defined in the kernel, e.g. atomic_add(),
atomic_dec(), etc. in the user space programs? 

I compiled the following program:

#include <asm-ppc/atomic.h>

int main()
{
	atomic_t atom;

	atomic_add(1, &atom);
	return (0);
}

I am able to compile it and the atomic_add seems to be
translated into the correct instructions. Can anybody
please confirm? Thanks.

Regards,

Terry Liang

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: atomic operations in user space

From: Arnd Bergmann <arnd@arndb.de>
Date: 2006-08-22 22:28:15

Am Tuesday 22 August 2006 22:50 schrieb Xupei Liang:
#include <asm-ppc/atomic.h>

int main()
{
=A0=A0=A0=A0=A0=A0=A0=A0atomic_t atom;

=A0=A0=A0=A0=A0=A0=A0=A0atomic_add(1, &atom);
=A0=A0=A0=A0=A0=A0=A0=A0return (0);
}

I am able to compile it and the atomic_add seems to be
translated into the correct instructions. Can anybody
please confirm? Thanks.
No, you can't do that, the kernel headers are not generally
working in user space, recent kernel versions protect you
from doing this.

If you don't have a library providing you with atomic operations,
you can copy the inline functions from the kernel, which will
work fine, but require that your app is GPL licensed.

	Arnd <><
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help