Erlang - 创建整数(分布式 pid 表示的一部分)实际上是如何创建的?
在分布式 Erlang 系统中,pid 可以有两种不同的表示形式: i) 内部; ii) 外部。
内部表示具有以下形状:< ABC >
外部表示(例如当消息必须穿过不同节点时使用)由以下元素组成: <; node_id、ID、序列号、创建>
根据官方文档。
其中node_id
是节点的名称,ID
和serial
标识node_id
和创建的进程
是一个整数,用于区分节点与其自身过去(崩溃)的版本。
我找不到的是虚拟机如何创建creation
整数。
通过在我的 PC 上设置一个小实验,我发现如果我多次创建并终止同一个节点,计数器总是增加 1,并且通过在不同的计算机上创建同一个节点,创建
整数虽然不同,但在结构上有一些相似之处,例如:
machine 1 -> creation integer = 1647595383
machine 2 -> creation integer = 1647596018
你们中有人知道这个整数是如何创建的吗?如果是这样,您能否向我解释一下并可能参考一些(或多或少)官方文档?
In a distributed Erlang system pids can have two different representations: i) internal; ii) external.
The internal representation has the following shape: < A.B.C >
The external representation, used for instance when a message has to travel across different nodes, is instead composed of the following elements: < node_id, ID, serial, creation >
according to the official documentation.
Where node_id
is the name of the node, ID
and serial
identify the process on node_id
and creation
is an integer used to distinguish the node from past (crashed) version of itself.
What I could not find is how the creation
integer is created by the VM.
By setting a small experiment on my PC, I have seen that if I create and kill the same node several times the counter is always increased by 1, and by creating the same node on different machines, the creation
integers are different, but have some similarities in their structure, for instance:
machine 1 -> creation integer = 1647595383
machine 2 -> creation integer = 1647596018
Do any of you have any knowledge about how this integer is created? If so could you please explain it to me and possibly reference some (more or less) official documentation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建
作为对epmd
中节点注册的响应的一部分发送,请参阅该协议的详细信息。如果您有自定义
erl_epmd
模块,您还可以提供自己的方式来创建creation
值。原始
创建
是具有该名称的节点首次注册时的本地时间,然后每次重新注册该名称时都会碰撞一次。The
creation
is sent as a part of the response to node registration inepmd
, see details on that protocol.If you have a custom
erl_epmd
module, you can also provide your own way of creating thecreation
-value.The original
creation
is the local time of when the node with that name is first registered, and then it is bumped once for each time the name is re-registered.