[erlang-questions] compare and set semantics using ets?

Anton Lebedevich <>
Mon Jan 14 16:13:27 CET 2013


On 01/14/2013 07:01 PM, Jesper Louis Andersen wrote:
> On Jan 14, 2013, at 1:08 PM, Anton Lebedevich <> wrote:
>
>> Is it possible to implement atomic compare-and-set semantics using ets?
> 
> Only in a limited fashion. I guess we either need a specific CAS-instruction, or you have to look up how it is achieved in mnesia, which does to transactional updates.

Good catch, I've completely forgot that mnesia already does it, will
take a look at its sources.

> CAS would relate to modern hardware implementations of software transactional memory.

One word CAS (Intel CMPXCHG) doesn't need bleeding edge hardware, it has
been there for quite a long time.

Regards,
Anton Lebedevich.



More information about the erlang-questions mailing list