Download presentation
Presentation is loading. Please wait.
Published byJeffery Woods Modified over 9 years ago
1
Programming Paradigms for Concurrency Pavol Cerny Vasu Singh Thomas Wies Part III – Message Passing Concurrency
2
The Downsides of Classical Shared Memory Concurrency shared memory typically implies physically shared memory locks: the “goto statements” of concurrency OS threads are resource-hungry and context-switching is expensive number of threads = number of available cores ≠ number of logical tasks number of threads = number of available cores ≠ number of logical tasks no natural adaptation to distributed settings reasoning about programs is (even more) difficult
3
Overview of Part III 1.Message Passing Programming Paradigms actors (Scala) first-class synchronous events (Concurrent ML) 2.MP Programming Techniques – client/server programming – process networks 3.Formal Semantics of MP Programs – process calculi 4.Formal Reasoning about MP Programs behavioral equivalences verifying safety and liveness properties
4
Actors object-oriented approach to concurrency “actor = object + logical thread” [Hewitt, Bishop, Steiger 1973, Agha 1986]
5
Actors actors perform local computations and communicate via MP communication is – asynchronous – buffered (in practice FIFO) – over unique-receiver channels (mailboxes) computation is – even-driven: react to incoming messages – dynamically create other actors – send messages to other actors – dynamically change behavior languages supporting actor-based concurrency – Erlang – Salsa – Scala – many implementations in form of libraries A A A A B B
6
Example: Ping-Pong Actors Ping Pong pong PingMsg
7
Example: Ping-Pong Actors Ping Pong pong PingMsg sender PongMsg
8
Example: Concurrent Merge Sort Sorter 1 523
9
Example: Concurrent Merge Sort Sorter 1 5 23
10
Example: Concurrent Merge Sort Sorter 1 5 2 3
11
Example: Concurrent Merge Sort Sorter 1 5 2 3
12
Example: Concurrent Merge Sort Sorter 1 5 2 3
13
Example: Concurrent Merge Sort Sorter 5 2 1 3
14
Example: Concurrent Merge Sort Sorter 3 2 5 1
15
CCS - A Process Calculus P,Q ::= 0 | A(a 1,…,a n ) | ¿.P | a?P | a!P | P “|” Q | P + Q | ( º a) P terminated process process identifier internal action input action output action parallel composition choice channel restriction
16
CCS - A Process Calculus Processes are defined by systems of recursive equations Ping(ping, pong)= Msg(ping) | (pong ? Ping(ping, pong)) Formal semantics given in terms of labeled transition systems ) enables formal reasoning about MP programs Diverge() = ¿.Diverge() Diverge() ´ ( º ping, pong) ((Ping(ping, pong) | Pong (ping, pong))) Pong(ping, pong) = ping ? (Msg(pong) | Pong (ping, pong)) Msg(a) = a ! 0
17
Project Proposals 1.Performance/Conciseness Evaluation of Concurrent Programming Paradigms Compare idiomatic implementations of the same algorithm in Scala using different programming paradigms: – a sequential implementation – a concurrent implementation based on actors – a concurrent implementation based on shared memory
18
Project Proposals 2.First-Class Synchronous Events in Scala – Take inspiration from the Scala Actor Library and the CML library – Implement a Scala library supporting first-class synchronous events.
19
Project Proposals 3.Verification of Scala Actor Programs –Implement a non-trivial Scala Actor program or take an existing one –Manually compute finite-state abstractions of all actors –Verify properties of the abstracted program using a formal verification tool for MP programs Please drop by or send me an email to discuss concrete projects!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.