atomic operations in user space

4 messages, 3 authors, 2006-08-25 · open the first message on its own page

atomic operations in user space

From: Terry Liang <hidden>
Date: 2006-08-23 19:03:35

Thanks. Arnd. My main concern is whether the operations are really atomic as they are in the kernel space. I have read some discussion in another forum that on other platforms, even if you are able to compile the atomic_add(), atomic_set(), etc. from an user space application,  they don't guarantee to be atomic. Thanks.

Regards,

Terry Liang

RE: atomic operations in user space

From: Li Yang-r58472 <hidden>
Date: 2006-08-24 10:38:50

Why do you need atomic operations in user land?  IPC will be sufficient
to deal with race conditions between processes.=20

Best Regards,
Leo
-----Original Message-----
From: linuxppc-embedded-bounces+leoli=3Dfreescale.com@ozlabs.org
[mailto:linuxppc-embedded-bounces+leoli=3Dfreescale.com@ozlabs.org] On
Behalf Of
Terry Liang
Sent: Thursday, August 24, 2006 3:04 AM
To: linuxppc-embedded@ozlabs.org
Subject: atomic operations in user space
=20
Thanks. Arnd. My main concern is whether the operations are really
atomic as they
are in the kernel space. I have read some discussion in another forum
that on other
platforms, even if you are able to compile the atomic_add(),
atomic_set(), etc.
from an user space application,  they don't guarantee to be atomic.
Thanks.
=20
Regards,
=20
Terry Liang

Re: atomic operations in user space

From: Brent Cook <hidden>
Date: 2006-08-24 14:18:32

On Thursday 24 August 2006 05:39, Li Yang-r58472 wrote:
Why do you need atomic operations in user land?  IPC will be sufficient
to deal with race conditions between processes.

Best Regards,
Leo
What about multiple threads within a process updating a counter?

Of course, if you look at these functions in the kernel header, they're just 2 or 3 inline assembly calls - you could easily rewrite them. Google for 'PowerPC atomic increment' and grab one of the unencumbered implementations if you need to use it in a non-GPL program.

On the other hand, I see no license at the top of my /usr/include/asm-i386/atomic.h file at all, same for PowerPC - are Linux header files actually GPL or are they more like the glibc headers, with exceptions made for userspace programs?

The atomic operations on x86 were accidentally exported early on, so they have to hang around apparently for compatibility (there are some mailing list threads out there to this effect.) Currently, you just have to assume in Linux that if you include something from /usr/include/linux or asm that it will not necessarily be cross-version or cross-architecture compatible. Not every arch in Linux even has atomic operations of this nature, which I guess is the main reason why they are not exported in general.

 - Brent
quoted
-----Original Message-----
From: linuxppc-embedded-bounces+leoli=freescale.com@ozlabs.org
[mailto:linuxppc-embedded-bounces+leoli=freescale.com@ozlabs.org] On
Behalf Of
quoted
Terry Liang
Sent: Thursday, August 24, 2006 3:04 AM
To: linuxppc-embedded@ozlabs.org
Subject: atomic operations in user space

Thanks. Arnd. My main concern is whether the operations are really
atomic as they
quoted
are in the kernel space. I have read some discussion in another forum
that on other
quoted
platforms, even if you are able to compile the atomic_add(),
atomic_set(), etc.
quoted
from an user space application,  they don't guarantee to be atomic.
Thanks.
quoted
Regards,

Terry Liang
_______________________________________________
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded

RE: atomic operations in user space

From: Li Yang-r58472 <hidden>
Date: 2006-08-25 02:33:03

-----Original Message-----
From: Brent Cook [mailto:bcook@bpointsys.com]
Sent: Thursday, August 24, 2006 10:18 PM
To: linuxppc-embedded@ozlabs.org
Cc: Li Yang-r58472; Terry Liang
Subject: Re: atomic operations in user space
=20
On Thursday 24 August 2006 05:39, Li Yang-r58472 wrote:
=20
quoted
Why do you need atomic operations in user land? IPC will be
sufficient
=20
quoted
to deal with race conditions between processes.
=20
quoted
=20
quoted
Best Regards,
=20
quoted
Leo
=20
What about multiple threads within a process updating a counter?
Is there anything preventing semaphore to be used in threads?
=20
Of course, if you look at these functions in the kernel header,
they're just 2 or
3 inline assembly calls - you could easily rewrite them. Google for
'PowerPC atomic
increment' and grab one of the unencumbered implementations if you
need to use it
in a non-GPL program.
=20
On the other hand, I see no license at the top of my
/usr/include/asm-i386/atomic.h
file at all, same for PowerPC - are Linux header files actually GPL or
are they
more like the glibc headers, with exceptions made for userspace
programs?
=20
The atomic operations on x86 were accidentally exported early on, so
they have to
hang around apparently for compatibility (there are some mailing list
threads out
there to this effect.) Currently, you just have to assume in Linux
that if you
include something from /usr/include/linux or asm that it will not
necessarily be
cross-version or cross-architecture compatible. Not every arch in
Linux even has
atomic operations of this nature, which I guess is the main reason why
they are
not exported in general.
=20
- Brent
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help