Posts Tagged ‘concurrent programming

30
Jul
09

using concurrency primitives

Everything we’ve learned about sequential programming is still true
for concurrent programming. All we have to do is to add the following
primitives:

Pid = spawn(Fun)
Pid ! Message
receiveend

Pid = spawn(Fun)

Creates a new concurrent process that evaluates Fun. The new
process runs in parallel with the caller. spawn returns a Pid (short
for process identifier). You can use Pid to send messages to the
process.

Pid ! Message

Sends Message to the process with identifier Pid. Message sending
is asynchronous. The sender does not wait but continues with
what it was doing. ! is called the send operator.
Pid ! M is defined to be M—the message sending primitive ! returns
the message itself. Because of this, Pid1 ! Pid2 ! … ! M means send
the message M to all the processes Pid1, Pid2, and so on.

receiveend

Receives a message that has been sent to a process. It has the following skeleton :

receive
_ ->
ok
end.

To be continue with simple example …

24
Jul
09

Concurrent Programming

• Creating and destroying processes is very fast.
• Sending messages between processes is very fast.
• Processes behave the same way on all operating systems.
• We can have very large numbers of processes.
• Processes share no memory and are completely independent.
• The only way for processes to interact is through message passing.

Erlang and so much more !




 

May 2012
M T W T F S S
« Apr    
 123456
78910111213
14151617181920
21222324252627
28293031  

del.icio.us

Con gái yêu.

CIMG0003

16/01/2010

Đầu tóc rối tung ...

More Photos

jabber

cuonglb@jabber.mobi
cuonglb@jabber.org
cuonglb@gmail.com
cuonglb@facemain.com
cuong@livemarkets.com
cuonglb@moo.im
cuonglb@jabber.snc.ru
cuonglb@alpha-labs.net
cuonglb@jaim.at
cuonglb@jabber.bluendo.com

Twitter Updates


Follow

Get every new post delivered to your Inbox.