Erlang - 创建整数(分布式 pid 表示的一部分)实际上是如何创建的?

发布于 2025-01-15 02:59:14 字数 766 浏览 5 评论 0原文

在分布式 Erlang 系统中,pid 可以有两种不同的表示形式: i) 内部; ii) 外部。
内部表示具有以下形状:< ABC >

外部表示(例如当消息必须穿过不同节点时使用)由以下元素组成: <; node_id、ID、序列号、创建>根据官方文档
其中node_id是节点的名称,IDserial标识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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

数理化全能战士 2025-01-22 02:59:14

创建作为对epmd中节点注册的响应的一部分发送,请参阅该协议的详细信息

如果您有自定义 erl_epmd 模块,您还可以提供自己的方式来创建 creation 值。

原始创建是具有该名称的节点首次注册时的本地时间,然后每次重新注册该名称时都会碰撞一次。

The creation is sent as a part of the response to node registration in epmd, see details on that protocol.

If you have a custom erl_epmd module, you can also provide your own way of creating the creation-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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文