I'm also quite interested in the internals of ets implemenatation. I've searched through the source code found ets.erl but it says there that the greater part of ets functions are implemented as BIFs but I can not find the source code for them - where is it?
<br><br>Regards,<br>Kirill<br><br><div><span class="gmail_quote">On 12/23/06, <b class="gmail_sendername">Yariv Sadan</b> <<a href="mailto:yarivvv@gmail.com">yarivvv@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
(I'm replying again to include the list)<br><br>> A normal way to provide concurrent access to a critical<br>> region in Erlang is to use a process to serialize the<br>> accesses. This is really not much different from guarding
<br>> a critical region using semaphores - only much simpler.<br>> It is also quite fast.<br>><br>> Mnesia uses ets (or dets) tables, which can be accessed<br>> concurrently by different processes. All reads and writes
<br>> are atomic, which means that they are serialized at the<br>> lowest level (similar to always using write locks in a<br>> threaded application).<br><br><br>Thanks for the response. It gave me a much better understanding of how
<br>ets/Mnesia works.<br><br>I'm interested in the mechanism behind ets, and how ets is different<br>from other types of shared memory. It sounds like ets is basically a<br>high-level shared memory implementation for Erlang, where that all
<br>reads and writes are atomic, and writes also lock the data to prevent<br>other readers and/or writers from accessing it while it's being<br>written. So, in a sense, ets is somewhere between regular shared<br>memory, as in C/Java, and Haskell-style STM, which provides
<br>transactionality similar to the one Mnesia provides for ets. If I<br>understand it correctly, then, it's not precise to say that Erlang<br>processes can't have shared memory, but that the Erlang runtime<br>provides a safe, high-level shared memory implementation called 'ets',
<br>that can also be accessed transactionally using Mnesia.<br><br>This is all very interesting to me because the ets interface makes it<br>seem as if an ets table is basically a dict hidden behind a<br>gen_server, but ets actually has unique concurrency characteristics
<br>that can't be implemented in pure Erlang.<br><br>I hope I'm not too far off track here... :)<br><br>Regards,<br>Yariv<br>_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">
erlang-questions@erlang.org</a><br><a href="http://www.erlang.org/mailman/listinfo/erlang-questions">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br>