[erlang-questions] Global lock is unfair?

Dan Gudmundsson dangud@REDACTED
Tue May 15 09:46:43 CEST 2018


If you are already using mnesia you can use mnesia:lock({global, GlobalKey,
Nodes}, write|read) but you will have to run it in a
transaction on nodes where mnesia is running.

/Dan


On Mon, May 14, 2018 at 11:53 PM Ryan Stewart <zzantozz@REDACTED> wrote:

> Funneling all the calls through a single process would bring the system to
> a grinding halt. Sure, I could write a system of processes, each of which
> acts as a mutex to one, particular resource, but why would I want to? All I
> need is locking, just like global locks, but fair. It seems like something
> that should already exist in a proven library.
>
>
> On Mon, May 14, 2018 at 3:41 PM Michael Truog <mjtruog@REDACTED> wrote:
>
>> Use a single Erlang process.  It will only be able to handle a single
>> message at a time (other messages will get queued in-order) and the
>> behavior will be fair.
>>
>> On 05/14/2018 12:55 PM, Ryan Stewart wrote:
>>
>> My team has used global:set_lock() to implement a sort of simple mutex
>> system on a set of resources. It turns out that this function seems to have
>> no concept of fairness. One process might request a lock and not get it
>> until 20 other processes have requested and gotten said lock, out of
>> request order. Is there any easy way to do fair locking?
>>
>> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180515/a7d77a21/attachment.htm>


More information about the erlang-questions mailing list