Concurrent code and expensive instructions
Posted Feb 10, 2011 22:24 UTC (Thu) by Julie
(✭ supporter ✭
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)