[erlang-questions] Asynchronous I/O - Getting documentation.

Ulf Wiger ulf.wiger@REDACTED
Fri Jul 8 17:06:32 CEST 2011


Well, IO is really synchronous from the point of view of the caller. That is, the erlang process requesting input or output is blocked while waiting for the service to be performed. In erlang terms, it performs a synchronous call (i.e. sends a message and waits for the result in a "selective receive" statement) to another erlang process. 

The request may be dispatched in different ways depending on the system. If the erlang node in question doesn't have a terminal, the request may be served transparently on another node, which does. For example, if a function is executed on a remote erlang node via an rpc:call(), any io effected by the called function will be automatically routed back to the calling node. As a result, if you call 

rpc:call(OtherNode, io, format, ["hello~n"]), 

the output, "hello", will appear in the shell of your own node - not on OtherNode. This is very useful, not least when debugging embedded systems.

The runtime system itself either performs non-blocking IO or dispatches an OS thread to perform blocking IO. This is an implementation detail that the erlang program itself has no control over.

BR,
Ulf W

On 7 Jul 2011, at 04:37, Ale wrote:

> Hello All,
> 
> I'm looking for documentation to expand my knowledge of the
> implementation of how asynchronous I/O works; from wikipedia.
> 
> """This approach is also used in the Erlang programming language
> runtime system. The Erlang virtual machine uses asynchronous IO using
> a small pool of only a few threads or sometimes just one process, to
> handle IO from up to millions of Erlang processes. IO handling in each
> process is written mostly using blocking synchronous I/O. This way
> high performance of asynchronous I/O is merged with simplicity of
> normal IO. Many IO problems in Erlang are mapped to message passing,
> which can be easily processed using built-in selective receive."""
> 
> I'm interested in learning how the scheduler works, and how the
> process which handle IO work.
> 
> Thanks,
> -- 
> Ale.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

Ulf Wiger, CTO, Erlang Solutions, Ltd.
http://erlang-solutions.com






More information about the erlang-questions mailing list