Spin locks?
I think it worth noting that spin locks are an efficency hack for SMP machines which are useful under a small number of situations. Moreover, there is nothing that prevents you from using spin locks all the time (other than a slight loss of efficency). In particular, in some libraries ALL locks are actually spin locks. Solaris 2.6 (or is that 7?) and above for example. If you call pthread_mutex_lock() on an MP machine & the lock is held by a thread currently running on another CPU, you WILL spin for a little while. It is very unlikely you would EVER want to build a spin lock yourself. (I mean, it would be kinda FUN and interesting, but not practical.) If you *really* want to, go ahead, just time your program carefully. $10 says you’ll find home-spun spin locks won’t help. > > BTW, SMP is a bad design that scales poorly. I wish someone could come > up with a better design with some local memory & some shared memory > instead. Like democracy. It sucks, but we haven’t come up with anythin