Avatar of shiningram
shiningram

asked on 

Atomic operations in assembly

Hi,
I want to write atomic operations (incr, dec, xchg, mod) which should support on almost all architectures.
Can anyone point me to resource available on thsi on net or in EE?

Someone explain what each following line is doing?

int32 func()
{
   int32 val = -1;

    asm volatile ("lock; xaddl %0,%1"
              : "=r" (val), "=m" (*mem)
              : "0" (val), "m" (*mem)
              : "memory", "cc");
 return val;
}

=r
=m
"0"
"m"
"memory"

What all these  above do? Can someone explains all these? I am looking for resource/tutorial to understand these.

Thanks,
Ram
AssemblyOperating SystemsC

Avatar of undefined
Last Comment
shiningram
SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of NovaDenizen
NovaDenizen

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of shiningram
shiningram

ASKER

Ravenpl you gave a great start and NovaDenizen you are awesome. You will be rewarded points when i close the question.
Can some one help writting increment and decrement atomic operations for linux and windos for 32 and 64 architecture.
Thanks,
Ram
SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of shiningram
shiningram

ASKER

Another question added to get clear suggestion from experts
Operating Systems
Operating Systems

Operating systems perform basic tasks, such as recognizing input from the keyboard, sending output to the display screen, keeping track of files and directories on the disk, and controlling peripheral devices such as disk drives and printers. For large systems, the operating system makes sure that different programs and users running at the same time do not interfere with each other. The operating system is also responsible for security, ensuring that unauthorized users do not access the system. Operating systems provide a software platform on top of which other programs, called application programs, can run.

37K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo