Is how distribution "works" specified anywhere?

Luke Gorrie <>
Mon May 17 17:25:25 CEST 2004


Joe Armstrong <> writes:

>   Is there any internal  documentation that specifies how distribution
> works?

In "on the wire" terms, check out this file in the OTP sources:

  erts/emulator/internal_doc/erl_ext_dist.txt  

The distribution messages all map simply onto BIFs (SEND, EXIT, etc)
and it's easy to understand.

>   How  are  things  organised  with  remote Pids?   is  a  remote  Pid
> distinguishable from a  local Pid - if  so how?

The PID structure includes a node name.

> If a remote Pid is sent in a message how does the destination
> machine know that it is a remote Pid?
>
>   Given an  expression:
>
> 	Pid  ! Message 
>
>   which software  figures out if  this is a  local message send,  or a
> send to a remote machine?

Can you read Emacs Lisp? I have a pretty small and simple erlang
runtime system with distribution in Distel. For example, here is the
`!' bif:

  (defun erl-send (who message)
    "Send the term MESSAGE to the process WHO.
  WHO can be a pid, a registered name (symbol), or a tuple of
  \[REGISTERED-NAME NODE]."
    (cond ((erl-null-pid-p who)
           (erl-lose-msg message))
          ((erl-local-pid-p who)
           (when (erl-local-pid-alive-p who)
             (erl-deliver-message who message)))
          ((erl-remote-pid-p who)
           (erl-dist-send who message))
          ((symbolp who)
           (let ((proc (erl-whereis who)))
             (if proc
                 (erl-send proc message)
               (erl-exit (tuple 'badarg (tuple 'not-registered who))))))
          ((tuplep who)			; [tuple NAME NODE]
           (erl-dist-reg-send (tuple-elt who 2) (tuple-elt who 1) message))
          (t
           (error "Bad pid: %S" who))))

Cheers,
Luke




More information about the erlang-questions mailing list