To be very clear. If you care about optimization cache lines
and lock hold times (to keep contention down) are the important
things.
With spin locks you have to be a little more careful to put them
on the same cache line as your data and to keep should hold times
short. With atomic ops you get that automatically.
There is really no significant advantage in either approach.
The number of atomic ops doesn't matter. You bring in
the cache line and manipulate it. The expensive part is
acquiring the cache line exclusively. This is expensive even if
things are never contended but there are many users.
Sorry for the rant, but I just wanted to set the record straight.
spin_locks vs atomic ops is a largely meaningless debate.
Eric
-