Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module(procslinked).
- -compile([export_all]).
- starter() ->
- StarterPid = erlang:self(),
- spawn(?MODULE, the_first_p, [StarterPid]),
- receive
- {Pid, init_done} ->
- io:format("Receive init_done from P1~n"),
- {Pid, okbeud}
- end.
- the_first_p(StarterPid) ->
- MyPid = erlang:self(),
- register(pidfirstp, MyPid),
- StarterPid ! {MyPid, init_done},
- spawn_link(?MODULE, the_second_p, [MyPid]),
- the_first_p().
- the_first_p() ->
- receive
- {Pid, init_done} ->
- io:format("Receive init_done from P2~n"),
- {Pid, okbeud};
- {From, "to first p", Msg} ->
- From ! {self(), "the_first_p()", Msg}
- end,
- the_first_p().
- the_second_p(StarterPid) ->
- MyPid = erlang:self(),
- register(pidsecondp, MyPid),
- StarterPid ! {MyPid, init_done},
- spawn_link(?MODULE, the_third_p, [MyPid]),
- the_second_p().
- the_second_p() ->
- receive
- {Pid, init_done} ->
- io:format("Receive init_done from P3~n"),
- {Pid, okbeud};
- {From, "to second p", Msg} ->
- From ! {self(), "the_second_p()", Msg}
- end,
- the_second_p().
- the_third_p(StarterPid) ->
- MyPid = erlang:self(),
- register(pidthirdp, MyPid),
- StarterPid ! {MyPid, init_done},
- the_third_p().
- the_third_p() ->
- receive
- {From, "to third p", Msg} ->
- From ! {self(), "the_third_p()", Msg}
- end,
- the_third_p().
- call_the_first() ->
- pidfirstp ! {self(), "to first p", "Halo first p!"},
- receive
- {Pid, FuncName, Msg} ->
- {Pid, FuncName, Msg}
- end.
- call_the_second() ->
- pidsecondp ! {self(), "to second p", "Halo second p!"},
- receive
- {Pid, FuncName, Msg} ->
- {Pid, FuncName, Msg}
- end.
- call_the_third() ->
- pidthirdp ! {self(), "to third p", "Halo third p!"},
- receive
- {Pid, FuncName, Msg} ->
- {Pid, FuncName, Msg}
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement