|
|
Log in / Subscribe / Register

Concurrent code and expensive instructions

Concurrent code and expensive instructions

Posted Feb 10, 2011 22:24 UTC (Thu) by Julie (guest, #66693)
Parent article: Concurrent code and expensive instructions

A really absorbing article.
I find Paul's Quick Quiz feature incredibly useful too by helping the points he's making sink in more thoroughly, particularly as I read LWN mostly late at night when my mental acuity is past its best ;-/
It would be great if more technical articles or discussions included this. One tiny niggling point with Quick Quiz 1 though:

Is atomic_add_return() SNC? In other words, are multiple concurrent calls to this function SNC?

Answer: Yes. Suppose that an atomic_t variable named a is initially zero and that a pair of concurrent atomic_add_return(1, &a) functions execute. The first one to execute will return zero, and the second one will return one.

I think atomic_add_return() returns the result not the initial value, so the first one to execute will return one, and the second one will return two, right? :-)


to post comments

Concurrent code and expensive instructions

Posted Mar 25, 2011 3:10 UTC (Fri) by PaulMcKenney (✭ supporter ✭, #9624) [Link]

You are quite correct. I was confusing atomic_add_return() with the x86 xadd instruction. Not quite the same!


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds