Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Spin locks?

locks spin
0
Posted

Spin locks?

0

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

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123