如何更改Erlang VM以将随机 128 位值用于其中一个 pid 值?
此时我可以设置的最大值似乎是:
32> pid(1, 32767, 8191).
** exception error: bad argument
in function list_to_pid/1
called as list_to_pid("<1.32767.8191>")
in call from c:pid/3 (c.erl, line 419)
33> pid(0, 32767, 8191).
<0.32767.8191>
看起来 pid 的生成归结为以下内容erts/emulator/beam/erl_ptab.h:283
:
ERTS_GLB_INLINE Eterm
erts_ptab_make_id(ErtsPTab *ptab, Eterm data, Eterm tag)
{
HUint huint;
Uint32 low_data = (Uint32) data;
low_data &= (1 << ERTS_PTAB_ID_DATA_SIZE) - 1;
low_data <<= ERTS_PTAB_ID_DATA_SHIFT;
huint.hval[ERTS_HUINT_HVAL_HIGH] = erts_ptab_data2pix(ptab, data);
huint.hval[ERTS_HUINT_HVAL_LOW] = low_data | ((Uint32) tag);
return (Eterm) huint.val;
}