----- Original Message ----
From: Mohammad M Molla <[EMAIL PROTECTED]>
To: [email protected]
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.





      
____________________________________________________________________________________
Catch up on fall's hot new shows on Yahoo! TV. Watch previews, get listings, 
and more!
http://tv.yahoo.com/collections/3658 

Reply via email to