On Nov 12, 2010, at 8:02 PM, Johnny Billquist wrote: > On 2010-11-13 04:49, Matt Thomas wrote: >> >> simple locks are not mutexes. mutexes are more complex and >> test-and-set isn't adequate to do the job. > > I (obviously) totally disagree... :-) > A mutex is simply just an object that only one entity can own at a time. > Hence "mutex", or mutually exclusive. A test-and-set is precisely all that is > needed to implement this. > And if you implement a mutex with spin locking, then you also need to make > sure that you do not get deadlocks. Either by detecting such things, or make > sure they don't happen. But that is outside the subject of the test-and-set > part.
Execpt most of our mutexes are sleep mutexes. Only a small minority are spin mutexes and those are already implemented using BBSSI/BBCCI.