Use of spinlocks in Erlang
Jesper Louis Andersen
Wed Jan 15 17:40:54 CET 2020
On Tue, Jan 7, 2020 at 10:01 AM Andreas Schultz <
> Could any of the Erlang gurus or ERTS developers comment on the use of
> home grown mutexes and spinlocks in Erlang in light of that discussion?
Not a locking expert in the ERTS, but:
The locking API is there to provide a factoring point for the BEAM. The
idea is that we have a locking API to use in ERTS which then maps to
different implementations as we see fit. This allows us to target both
UNIX, Windows, and embedded OS'es at the same time, with a consistent API.
But it gets better than that!
We can use the factoring point to "plug in" different locking models and
try them out. This allows us to choose a locking model which works well. It
also allows us to plug in various debugging/correctness checks at compile
time. For instance that lock ordering is preserved, if locks are contended
on, or if a deadlock happened.
That is, the current locking model is sort-of chosen at compile time, based
on the capabilities of the underlying system.
All in all, I'm going to claim that the system is not so much "home grown"
as it is a sensible wrapper around an underlying system.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions