3

I have four Erlang nodes working together on multi-process application. In my order one process is monitoring which draws the location of the processes on the area and the three other nodes handle the processes location and movement. On the monitor I use an ETS database to store the locations when the key is the process PID. I have noticed that the nodes creates processes which have the same PIDs which obviously interrupts with the management of the entire system.

I have tried to connect the processes with:

net_adm:ping(...).
net_kernel:connect(...).

I was hoping that when the nodes will be aware of each other they will give different PIDs but that did not work.

2240
  • 1,547
  • 2
  • 12
  • 30
antonpuz
  • 3,256
  • 4
  • 25
  • 48

1 Answers1

7

The PIDs may be printed the same, e.g. <0.42.0>, but that's just an output convention: PIDs on the local node are printed with the first number being 0. If you'd send this PID to another node and print it there, it would be printed as <2265.42.0> or similar. PIDs are always associated with the name of the node where the process is running, and you can extract it with node(Pid). Therefore, PIDs from different nodes will never compare equal.

This answer goes into more details about the structure of a PID.

Community
  • 1
  • 1
legoscia
  • 39,593
  • 22
  • 116
  • 167
  • 1
    you are correct, i just sent self() from different nodes and altho it showed the PID with 0 in suffix on the sending node it showed it with 6832 on the receiving node. thank you very much! – antonpuz Jul 25 '14 at 14:15