[erlang-questions] Freezing a process

Ulf Wiger ulf.wiger@REDACTED
Sat May 29 05:51:38 CEST 2010


On 05/29/2010 12:18 AM, Jeffrey Rennie (レニー) wrote:
> 
> In other light-weight concurrency solutions I've seen, such as
> stackless Python, it's straight-forward to serialize processes.  I was
> afraid I had overlooked something in Erlang.

In Termite (http://code.google.com/p/termite/), which is a Scheme
dialect inspired by Erlang, it is also possible to migrate a
process.

In Erlang, it isn't possible to do it in a generic way, and
transparently. There are a few details that get in the way, such
as that the owner of a port must be a local process, and ports
are by design not possible to move transparently.

This is actually more or less an original design philosophy of
Erlang. It was designed to support distribution transparency,
such that it shouldn't matter where the other processes are,
that are talking to you. At the same time, it had to be
possible to be very explicit about where you spawn a process,
since, if a process controls a hardware device, it should be
running in a place where this is at all possible to do.

Another issue is that new failure conditions arise when
crossing a node boundary (such as disrupted communication and
partial failure), and it is sometimes necessary to take this
into account in your program.

These things are not necessarily anathema to allowing the
migration of processes. One could imagine a process flag
forbidding the migration, for cases where the programmer
thinks that code would break. But the OTP design philosophy
is rather to move whole applications and being rather
explicit about node boundaries, such that an OTP application
instance always belongs to a specific node.

OTOH, if a process is designed to be easily movable, in that
it has no tricky local dependencies, it is trivial to write
a migrate() function for it. If it is a behaviour, the sys
module provides the means to suspend a process, extract its
state, and resume it. But in the case of migration, you would
rather start the process in its new location with the
migrated state, and e.g. use the gen_server:enter_loop()
function to resume it.

BR,
Ulf W
---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com



More information about the erlang-questions mailing list