Working further on the userspace implementation locks, I realized that it is hard to come up with an implementation that is both fast and fair, understanding by the last concept the fact that all threads have more or less the same chances to acquire a lock. POSIX threads seem to acomplish this nicely, at least on OS X, but they can afford some collaboration with the OS scheduler that we do not have.<div>

<br></div><div>So far the trick that works best at this seems to be a trivial change: before acquiring a lock, verify whether the lock wait queue is empty or not. If it is not empty, queue its own process and wait. This has the disadvantage that a thread that might be ready might not end up using the resource which is locked.</div>

<div><br></div><div>So my question is to what extend is fairness something that has to be implemented by the operating system or by the user him/herself? Is it something that has to be contemplated at the application level?</div>

<div><br></div><div>Juanjo<br clear="all"><div><br></div>-- <br>Instituto de Física Fundamental, CSIC<br>c/ Serrano, 113b, Madrid 28006 (Spain) <br><a href="http://juanjose.garciaripoll.googlepages.com" target="_blank">http://juanjose.garciaripoll.googlepages.com</a><br>


</div>