On Thu, Feb 3, 2011 at 11:42 AM, Blaise Gassend wrote: >> It's the most elegant solution, but not cheap. >> >> On an SMP machine, suspending the current thread and checking all the >> run queues in case there is something waiting on this lock is an >> expensive operation. That's probably why Linux does not do it >> automatically when the lock is released. > > In this case you would be calling it once per frame. I would not worry > about the cost of that yield once per frame, or on the order of 100 > times per second. To put things into perspective, there are probably > many context switches happening to gather the frame. > > Putting it in automatically when the lock is released could cause > millions of yields per second depending on how locks are being used. > That would be a much greater cause for concern. Yes, that's all true. I was not really arguing that it would be too expensive to add the yield(), mainly just rationalizing why I don't want to change it. If you don't have a really good reason for doing something, it's best to have at least three bad ones. :-) If I'd thought of using yield() in the first place, I would have done it that way. --  joq