[erlang-questions] changing the internal message transfer protocol
Guilherme Silveira
guilherme.silveira@REDACTED
Sat Sep 26 21:21:27 CEST 2009
Thanks... found the source code I was looking for
Regards
Guilherme Silveira
Caelum | Ensino e Inovação
SP (11) 5571-2751 RJ (21) 2220-4156
Celular (11) 83358084
2009/9/25 Jachym Holecek <freza@REDACTED>:
> # Guilherme Silveira 2009-09-25:
>> >> Pid = spawn(NodeName, M, F, A).
>> > See lib/kernel/src/erlang.erl:spawn/4.
>> spawn invokes gen_server when NodeName =/= node(), which invokes
>> gen:call, which invokes erlang:send.
>>
>> But I was unable to find who exports erlang:send... the erlang module
>> (erlang.erl) only exports dsend, which connnects+invokes send.
>
> Yep, some of the functions in various "core" modules are implemented
> directly in C instead of the corresponding Erlang module. Such functions
> are called "builtin functions" and live in bif.c/erl_bif_${module}.c and
> possibly other places I missed, see below on how to lookup their home.
>
>> Reading the net_kernel and do_connect implementations, it seems as
>> connections are treated with their own local pids and kept alive. But
>> still...
>>
>> Any suggestions where to find the send implementation?
>
> Builtin functions are described in erts/emulator/beam/bif.tab, this
> is used to generate BIF dispatch table at compile time using the
> erts/emulator/utils/make_tables script. For send/2 we have:
>
> bif erlang:send/2
>
> which according to make_tables seems to mean (and my Perl-fu is very
> weak) that it's implemented by the send_2() function -- this lives
> in bif.c as "grep -rs '^send_2[(]' erts/" reveals.
>
> This has been a fair amount of guesswork; I'm sure someone will correct
> me if I'm wrong.
>
> HTH,
> -- Jachym
>
More information about the erlang-questions
mailing list