Re: User space atomic operation

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

 



On Fri, Nov 21, 2003 at 03:23:09PM -0700, Stuart Macdonald wrote:
> >>On Wed, 2003-11-05 at 01:51, Yao, Zhigang(Richard) wrote:
> >> Hi,
> >>
> >> I want to do the atomic operation ( such as i++ ) in user space, can I
> copy
> >> and include include/XXX/atomic.h directly?
> 
> >the answer is no. If you do that the operations aren't guaranteed to be
> >atomic (and probably arent even on x86)
> 
> >However glibc has primitives for this instead, as do helper libraries
> >like apr etc etc
> 
> Setting aside portability issue, the primatives in
> /include/asm-i386/atomic.h result in IA32 instructions (lock incl)
> which lock the bus around the inc instruction so the operation will in-fact
> be atomic - right?

if you look careful you'll see that it will only use lockl if CONFIG_SMP is
set. Which may be the case on your box... or not. 
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux