Re: xchg vs lock

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

 








----- Original Message ----
From: Mohammad M Molla <merajul_i@xxxxxxxxx>
To: kernelnewbies@xxxxxxxxxxxx
Sent: Monday, October 1, 2007 5:53:04 AM
Subject: xchg vs lock

Hi

Inside the kernel, I see in many places xchg is used to swap two pointers atomically? What is the difference between exchanging using xchg and getting lock, then exchange, then unlock? Is it only performance reason?

---------------------------------------------
xchg garantees the the atomicity of the exchange of pointes as its just one instruction. But if we do it the traditional way then we would need some protection frm other threads which might come in and change/use the valuse which are in the midist of exchanging....

CMIIW


regards
kanishk
---------------------------------------







Thanks,


- Meraj


Got a little couch potato?
Check out fun summer activities for kids.



Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.

[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