Re: atomic_add ?

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

 



On Mon 9 June 2003 00:37, Linux Newbie wrote:
> Hi,
>
> Can anybody explain what is going on this function?
>
> static __inline__ void atomic_add(int i, atomic_t *v)
> {
>      __asm__ __volatile__(

__asm__ tell gcc to insert the following assembly code
__volatile__ forbids gcc to  reorder asm instruction (prevents instruction reording )


>                LOCK "addl %1,%0"

LOCK locks memory bus until the instruction complete 

>                :"=m" (v->counter)

v->counter is an output memory operand.
= means output operand
m means memory operand
(...look at info gcc [Simple Constraints})


>                :"ir" (i), "m" (v->counter));

i   is an input immediate integer operand (ir)

>
> }
>
> I understand that the LOCK (0xf0) makes the instruction atomic on systems
> with multiple cpus. But besides that what is .. "=m", :"ir" etc?


Take a big look at info gcc.

Regards,
Daniele.






-------------------------------------------------------------------------------------------------------------------------------------------------------------
PGP PKEY      http://pgp.mit.edu:11371/pks/lookup?search=belch76@libero.it&op=index
ICQ#               104896040  
Netphone/Fax  178.605.7063
Homepage       http://web.tiscali.it/bellucda
-------------------------------------------------------------------------------------------------------------------------------------------------------------

Daniele Bellucci



--
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