atomic operations in user space
Arnd Bergmann
arnd at arndb.de
Wed Aug 23 08:23:31 EST 2006
Am Tuesday 22 August 2006 22:50 schrieb Xupei Liang:
> #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.
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 <><
More information about the Linuxppc-embedded
mailing list