LOGO Erlang 11 ACM 王浩然. Company Logo concurrency in real world in computer.

24
LOGO Erlang 11 ACM 王王王

Transcript of LOGO Erlang 11 ACM 王浩然. Company Logo concurrency in real world in computer.

Page 1: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

LOGO

Erlang11 ACM 王浩然

Page 2: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

concurrency

in real world

in computer

Page 3: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

concurrency

Here, we encounter a quz.

Page 4: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

concurrency

x = x+n. 1.mov ax,[bp +x] 2.mov bx,n 3.add ax,bx 4.mov[bp+x],ax

multi-process share the registers.

Page 5: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

concurrency

If there is a Way or PL supporting this?

Yes! COP, Erlang.

Page 6: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

concurrency

Let's change a model.

The relation of the multi-process to a computer

staff to a community

Page 7: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

concurrency

Properties:• Independent

• No sharing memory

• Sending message

Page 8: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

Concurrency Primitives

Pid = Spawn(fun)

Pid ! Message

receive ... end

Page 9: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Receive Pattern

Page 10: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

Concurrency

A simple model

Client & Server

Sending& Receiving

Page 11: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

rect

Page 12: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

clock

What if never receive a message? waiting forever?

after

Page 13: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.
Page 14: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.
Page 15: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.
Page 16: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

Other features

Variable!• no type declaration.

Page 17: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

Variable

A strange fact

Page 18: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

Variable

What on earth is going on here??

Explain• X not a variable• = is not an assignment operator

Why is this?

Page 19: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

Other features

"=", Pattern Matching Operator

can apply on storing compound data

Page 20: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

overload the function:

Page 21: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

Other features

Functional Programming• function: first class, same as other data types.

Page 22: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.
Page 23: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

Company Logo

Summary

Not totally understanding

Still Missed Many Advantage

Page 24: LOGO Erlang 11 ACM 王浩然. Company Logo concurrency  in real world  in computer.

LOGO