[Ecls-list] Mutex & fairness

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Sun Mar 25 19:44:02 UTC 2012

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.

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.

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?


Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20120325/cdfc07d2/attachment.html>

More information about the ecl-devel mailing list