Note series
Erlang environment and sequential Programming
Erlang concurrent programming
Erlang distributed programming
Yaws
Erlang/OTP
Date change description
2014-11-02AOutline, 1
Agenda
0 range
Real-world modeling method of Erlang
Erlang Process Creation
Erlang Process Design Mode
Erlang process error handling
1 Erlang concurrency modeling Philosophy
Armstrong jumped out of the urgency and eager to explain all-in-one solutions of programming languages in concurrent application scenarios in [2], and creatively proposed "temporarily forget programming, think about what is going on in the real world.
Solving the problem has always been advertised by CS scientists and IT engineers as a way to influence the real world, since computer science was questioned whether it should be a Discipline/science. Turing Machine, Feng? Noriman machines and quantum machines that I don't understand. Are they really the products of the bionic or the simulation of the real world? But they have indeed succeeded, it also affects the thinking of participants in the field. Using natural or artificial seems to be a taste problem. No!
The following is an excerpt from Armstrong's explanation:
We understand concurrency.
The world is parallel.
The Erlang program reflects how we think and communicate.
Humans act as independent individuals and communicate by sending messages.
If someone dies, others will notice it.
Erlang concurrency constructor Overview
Constructor |
Description |
PID =Spawn(Mod, func, argS) |
Create a process and execute mod: func (ARGs) |
PID!Message |
Send messages to processes |
Receive...End |
Receive messages |
Register(Anatom, pid) |
Registration Process |
Unregister(Anatom) |
Remove process registration name |
Whereis(Anatom)-> PID | undefined |
Check process registration name |
Registered()-> [Anatom: Atom ()] |
List of all registered PROCESSES IN THE SYSTEM |
Link(PID) |
Set two-way link between the call process and PID |
Unlink(PID) |
Remove Link |
Spawn_link(Mod, func, argS) |
Atomic operation: generate a process and set a two-way link |
Spawn_monitor(Mod, func, argS) |
Tuples: generate processes and set monitoring between calling processes and new processes. |
Process_flag(Trap_exit, flag) |
Set the invocation process as a system process |
Ref = Erlang:Monitor(Process, pid) |
Generate one-way monitoring of PID |
Erlang:Demonitor(Reference) |
Remove monitoring |
Erlang:Demonitor(Reference, [flush]) |
Remove monitoring, and clear information about the monitoring process mailbox |
Exit(Reason) |
Call the process to terminate the reason |
Exit(PID, reason) |
Sends an exit signal to the process PID |
2. Create a process
3. Process Design Mode
4 process error handling
References
[1] cesarini F., Thompson s.
ErlangProgramming Guide.
Beijing: Machinery Industry Press. 2011.
[2] Armstrong J. Translated by niucheng.
ErlangProgram Design(The2Version). (Programming Erlang, Second Edition-software for a concurrent World).
Beijing: People's post and telecommunications press. 2014.
[3] Logan M., Merritt E., Carlsson R.
Erlang/OTPConcurrent Programming Practice. (Erlang and OTP in action).
Beijing: People's post and telecommunications press. 2012.
Erlang 102 Erlang concurrent programming-shocould be done in