The future of concurrent programming
eao197
eao197 at intervale.ru
Wed May 30 08:03:15 PDT 2007
On Wed, 30 May 2007 18:01:26 +0400, Sean Kelly <sean at f4.ca> wrote:
>> Erlang's threads are better than fibers because they are pre-emptive.
>> However, this is only possible because Erlang runs on a VM.
>> Context-switching in the VM is much cheaper than in the CPU (ironically
>> enough), which means that D isn't going to get near Erlang's threads
>> except on a VM that supports it (somehow I doubt the JVM or CLR come
>> close).
>> Fibers are nice when you don't need pre-emption, but having to think
>> about pre-emption makes the parallelism intrude on your
>> problem-solving, which is what we would like to avoid.
>
> If I understand you correctly, I don't think either are a clear win.
> Preemptive multithreading, be it in a single kernel thread or in
> multiple kernel threads, require mutexes to protect shared data.
> Cooperative multithreading does not, but requires explicit yielding
> instead. So it's mostly a choice between deadlocks and starvation.
AFAIK, there isn't shared data in Erlang -- processes in Erlang VM
(threads in D) communicate each to another by sending and receiving
messages. And message passing mechanism is very efficient in Erlang VM.
--
Regards,
Yauheni Akhotnikau
More information about the Digitalmars-d
mailing list