Why do OS not support erlang's lightweight process?
Jacobo G. Polavieja
jacobopolavieja@REDACTED
Sat Sep 2 05:35:07 CEST 2006
Tony Finch wrote:
> On Tue, 29 Aug 2006, lang er wrote:
>
>> If OS support erlang's lightweight process in kernel, many programming
>> languages could have erlang's concurrent capability.I think it is not
>> impossible.
>
> The reason that Erlang processes are lightweight is that they do not
> require a context switch from userland -> kernel -> userland in order to
> schedule the next thread. Erlang can rely on the properties of the
> language, specifically no shared mutable data, in order to isolate
> processes from each other. The kernel must use the CPU's virtual memory
> support to do this, because it cannot make assumptions about the languages
> used to write userland processes, and switching pages tables is expensive.
>
> There have been some experiments with single-address-space operating
> systems, which should in principle be able to context switch faster (they
> only need to change the page table access rights, not the virtual -> real
> address mapping) but current CPUs are not optimised for this kind of
> design, so it isn't an advantage in practice. It also requires a 64 bit
> address space to be practical.
>
> Tony.
And wouldn't it be possible to implement a similar threading system in
other VM like, say, CLR (Mono VM)?
There lots of base differences from the Mono Framework to Erlang, but
maybe it's easier to implement more effective ways of concurrency with
VMs than with traditional languages. If so, MonoThreads, at present, map
to POSIX Threads, and that's something I would like to see improved now
that I'm starting to discover some of Erlang's benefits such as its
lightweight threads.
Right now there are some people making efforts such as MicroThreading
(which I'll have to read further through), and Continuations (which seem
to be similar also to MicroThreads). I just don't have any valuable
information on performance compared to POSIX Threads (well, MicroThreads
seem to be more efficient, but it's quite experimental), and neither any
comparison to other concurrency systems such as Erlang's.
Just in case someone is interested:
http://secondlife.blogs.com/babbage/2006/05/microthreading_.html
http://tirania.org/blog/archive/2006/Jun-07-1.html
http://tirania.org/blog/archive/2006/Apr-19-2.html
Sorry if I talked too much about Mono and this isn't the place to do it,
but is another of my bigger interests in software and I can't help
imagining new ways of improving it. I wish it had some of the benefits
Erlang offers. But nothing is perfect!
After this big chunk of speech, if anyone wants to bring up any
information it would make enormously happy.
Cheers!
More information about the erlang-questions
mailing list