Format of Pids

Rickard Green rickard.green@REDACTED
Tue Jun 3 14:51:34 CEST 2003


Hi,


Vance Shipley wrote:
  > What can be said about the format of Pids?
  >
  > Pids (and references and ports) look like:
  >     <0.11.0>
  >
  > These numbers seem to be refered to as num,
  > serial and creation.  What do these things mean?

Pids:

   <NodeId.Number.Serial>

NodeId is a node local number identifying another node. For example,
on node a@REDACTED NodeId for node b@REDACTED can be 4711, but on node c@REDACTED NodeId
for node b@REDACTED can be 17. 0 is special and means this node. On pre-R9B
nodes NodeId is an 8-bit unsigned integer. On R9B (and later) nodes
NodeId is a 32-bit (or 64-bit) unsigned integer.

Creation is an integer which identifies "the creation of a node".
Creation is incremented when a node is restarted. Currently creation
is a 2-bit unsigned integer. 0 is special and means something like:
actual creation used right now. Creation isn't shown when a pid is
printed.

Number and Serial are two integers identifying the process on the node
which the process resides on. Currently number is a 15-bit unsigned
integer and serial is a 3-bit unsigned integer.

Number used to (pre-R9B) be used as index into the process table
(an array), today the index might be a part of Number or a combination
of Number and a part of Serial.



Ports:
    #Port<NodeId.Id>

NodeId and Creation as for Pids.

Id is an integer identifying the port on the node which the port
resides on. Currently Id is an 18-bit unsigned integer.



References:
    #Ref<NodeId.Id3.Id2.Id1>

NodeId and Creation as for Pids.

The three unsigned integers Id1, Id2, Id3 are (almost) unique for
references created on the same node. Currently Id1 is an 18-bit
unsigned integer, and Id2 and Id3 are 32-bit unsigned integers,
i.e. there can at most be 2^82 unique references created on the same
node.

  > I am working with them in erl_interface and
  > would like to understand them better.  For instance if I want to
quickly test if a Pid
  > exists I could do if(pid->serial).  But is
  > that right or is num the right field to check?
  > Or do I really have to compare the whole
  > structure?

Yes, when testing for equality you have to compare the hole
structure.

  > I seem to see that the first field is '0' if
  > the Pid is local and something else if it's remote.  Is that number
  > the same on other nodes?

See above.

  >  I assume that these Pids are munged
  > on the way through the distribution.
  >

In the external format, nodename is used instead of NodeId.

  > Just curious ...
  >
  >     -Vance


Regards,
Rickard Green, Erlang/OTP, Ericsson AB






More information about the erlang-questions mailing list