asynchronous components -
TRANSCRIPT
![Page 1: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/1.jpg)
Asynchronous Components
Asynchronous communications: from calculi to distributed
components
![Page 2: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/2.jpg)
Synchronous and asynchronous languages
• Systems build from communicating components : parallelism, communication, concurrency
• Asynchronous Processes - Synchronous communications (rendez-vous)
- Asynchronous communications (message queues)
• Synchronous Processes (instantaneous diffusion)
Question on D. Caromel course: how do you classify ProActive ?
2
Process calculi: CCS, CSP, Lotos
SDL modelisation of channels
Esterel, Sync/State-Charts, Lustre
![Page 3: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/3.jpg)
Asynchrony in CCS
![Page 4: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/4.jpg)
Processes Calculi – what is asynchrony?
• A proposal in π-calculus: Asynchronous π-calculus • No consequence of output actions • Equivalent in CCS:
![Page 5: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/5.jpg)
Processes Calculi – what is asynchrony? (2)
• µ.P can be a.P, a.P, τ.P • An asynchronous version would be to allow only a.P, and τ.P, and simply a without suffix
• a.P has to be replaced by (a|P)
• A very simple notion but sufficient at this level • Same expressivity, but simple synchronisation can
become more complex
![Page 6: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/6.jpg)
Communication Ordering; A Deeper Study
Synchronous, asynchronous, and causally ordered communication
Bernadette Charron–Bost, Friedemann Mattern, Gerard Tel
1996
![Page 7: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/7.jpg)
Causality Violation
• Causality violation occurs when order of messages causes an action based on information that another host has not yet received.
P1
P2
P3
1 2
3 4
5
0
0
0
1
2
Physical Time
4 6
![Page 8: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/8.jpg)
The “triangle pattern”
A
C
B
2
1 (e.g., init)
3
Objective: Ensure that 3 arrive at C after 1.
![Page 9: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/9.jpg)
Mattern: Communication is not only synchronous or asynchronous
a ≺i b ⇒ a ≺ b
+ transitivity
If ≺ is a partial order (antisymetric) then it represents a valid asynchronous communication i.e. there must be no cycle of different events
![Page 10: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/10.jpg)
Synchronous communication
![Page 11: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/11.jpg)
FIFO
![Page 12: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/12.jpg)
Causal Ordering
![Page 13: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/13.jpg)
Applications
Such characterizations are useful for - Identifying coherent states (states that could exist) - Performing fault-tolerance and checkpointing - Study which algorithms are applicable on which
communication orderings - Might be useful for debugging, or replaying an
execution
![Page 14: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/14.jpg)
A “few” communication orderings
• Synchronous • FIFO channels • Causal ordering • Synchronous
• What is rendez-vous? What does rendez-vous ensure?
• So why is ProActive said asynchronous?
No event beteen sending and reception
![Page 15: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/15.jpg)
GCM: “Asynchronous” Fractal Components
![Page 16: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/16.jpg)
GCM – Quick Context
• Designed in the CoreGrid Network of Excellence, Implemented in the GridCOMP European project
• Add distribution to Fractal components • OUR point of view in OASIS: - No shared memory between components - Components evolve asynchronously
- Components are implemented in ProActive - Communicate by request/replies (Futures)
• A good context for presenting asynchronous components futures and many-to-many communications
![Page 17: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/17.jpg)
What are (GCM/Fractal) Components?
Bindings
Business code
Business code
Server interfaces
Client interfaces Primitive component
Primitive component
Composite component
NF (server) interfaces
![Page 18: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/18.jpg)
A Primitive GCM Component
CI.foo(p)
Primitive components communicating by asynchronous remote method invocations on interfaces (requests)
Components abstract away distribution and concurrency
in ProActive components are mono-threaded simplifies concurrency but can create deadlocks
![Page 19: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/19.jpg)
Composition in GCM
Bindings: Requests = Asynchronous method invocations
![Page 20: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/20.jpg)
Futures for Components
f=CI.foo(p) ………. f.bar() f.bar()
Component are independent entities (threads are isolated in a component)
+ Asynchronous method invocations with results
Futures are necessary
![Page 21: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/21.jpg)
Replies
f=CI.foo(p)
… … … f.bar()
![Page 22: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/22.jpg)
First-class Futures
f=CI.foo(p)
… … … CI.foo(f) CI.foo(f)
• Only strict operations are blocking (access to a future) • Communicating a future is not a strict operation
![Page 23: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/23.jpg)
First-class Futures and Hierarchy
Without first-class futures, one thread is systematically blocked in the composite component.
f=f’
![Page 24: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/24.jpg)
First-class Futures and Hierarchy
… … …
Almost systematic dead-lock in ProActive
A lot of blocked threads otherwise
![Page 25: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/25.jpg)
Reply Strategies
In ASP / ProActive, the result is insensitive to the order of replies (shown for ASP-calculus)
experiments with different strategies
![Page 26: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/26.jpg)
delta.send(result) result.bar() result.bar()
β α
δ
Future Update Strategies
γ
4 – Implementation Strategies Part V
![Page 27: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/27.jpg)
delta.send(result) result.bar() result.bar()
β α
δ
Future Update Strategies: Message-based
γ
4 – Implementation Strategies
Futu
re F
orw
arde
d M
essa
ges
Part V
![Page 28: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/28.jpg)
delta.send(result) result.bar() result.bar()
β α
δ
Future Update Strategies: Forward-based
γ
4 – Implementation Strategies Part V
![Page 29: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/29.jpg)
delta.send(result) result.bar() result.bar()
β α
δ
Future Update Strategies: Lazy Future Updates
γ
4 – Implementation Strategies Part V
![Page 30: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/30.jpg)
A Distributed Component Model with Futures
• Primitive components contain the business code
• Primitive components act as the unit of distribution and concurrency (each thread is isolated in a component)
• Communication is performed on interfaces and follows component bindings
• Futures allow communication to be asynchronous requests
• Futures are transparent can lead to optimisations and are a convenient programming abstraction but …
![Page 31: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/31.jpg)
What Can Create Deadlocks?
• A race condition:
• Detecting deadlocks can be difficult behavioural specification and verification techniques (cf Eric Madelaine)
![Page 32: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/32.jpg)
Collective Communications
Communications are not necessarily one-to-one: • One-to-many • Many-to-One
• M by N
![Page 33: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/33.jpg)
Collective Communications
• Simple type system • Component type = types of its interfaces • Interface type : - Name - Signature - Role - Contingency - Cardinality extended to support multicast / gathercast
Fractal type-system
![Page 34: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/34.jpg)
Multicast interfaces
Transform a single invocation into a list of invocations
• Multiple invocations - Parallelism - Asynchronism - Dispatch
• Data redistribution (invocation parameters) - Parameterisable distribution function - Broadcast, scattering - Dynamic redistribution (dynamic dispatch)
• Result = list of results
![Page 35: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/35.jpg)
![Page 36: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/36.jpg)
Ordering and Multicast
• FIFO ordering: If a correct process issues multicast(i,m) and then multicast(i,m’), then every correct process that delivers m’ will deliver m before m’.
• Causal ordering: If multicast(i,m) precedes multicast(i’,m’) with i abd i’ containing the same elements then any correct process that delivers m’ will deliver m before m’.
• Totally ordering (determinism): If a correct process delivers message m before m’, then any other correct process that delivers m’ will deliver m before m’.
![Page 37: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/37.jpg)
Gathercast interfaces
Transform a list of invocations into a single invocation
• Synchronization of incoming invocations - ~ “join” invocations - Timeout / drop policy - Bidirectional bindings
(callers callee) • Data gathering
Aggregation of parameters into lists
• Redistribution of results Redistribution function
![Page 38: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/38.jpg)
Collective interfaces
• Specific API manage collective interfaces and reconfigure them (add client, change policy, …)
Allow MxN communications: Redistribution and direct
communications for many-to-many communications
![Page 39: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/39.jpg)
The MxN Problem (1)
M components
N components
![Page 40: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/40.jpg)
The MxN Problem (2)
CM
CN
Coupling controllers
![Page 41: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/41.jpg)
The MxN Problem (3)
M components
N components
![Page 42: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/42.jpg)
The MxN Problem (4): data distribution
M components
N components
invocation parameters
![Page 43: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/43.jpg)
Summary of Collective Communications
• Simple way of specifying collective operations • + definition at the level of the interfaces better for
verification and specification • Rich high levels spec of synchronisation (especially
gathercast) • Easier to optimize - The MxN case: synchronisation issues, complex
distribution policies avoid bottleneck
![Page 44: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/44.jpg)
A few things we did not cover
• SPMD programming and Synchronization Barriers, cf gathercast???
• Group communications ~ Multicast • Purely synchronous models -> Robert de Simone • Shared memory models
• … and a lot of more complex communication models
![Page 45: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/45.jpg)
Conclusion
• An overview of asynchronism and different communication timings
• Applied to components with richer language constructs (futures, collective interfaces, …)
• Still a lot of other distributed computing paradigms exist (Ambient Talk, creol, X10 for example)
• A formalism for expressing communication ordering
![Page 46: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/46.jpg)
Exercises
![Page 47: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/47.jpg)
Exercise 1: Request queue
• In CCS with parameters (a value can be a request) - Express a request queue:
- Also express 2 simple processes accessing it
• Same thing in asynchronous CCS (without and with RDV)
Request queue !Enqueue(R)
?Dequeue(R)
Hint from last course: Regi = read(i ).Regi + write(x ).Reg x
![Page 48: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/48.jpg)
Exercise 2: Are the execution CO, synchronous, asynchronous or FIFO?
![Page 49: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/49.jpg)
![Page 50: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/50.jpg)
Exercise 3: find a solution to the deadlock slide 31
![Page 51: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/51.jpg)
Exercise 4: Ensuring causal ordering with a sending queue
In the example below, suppose that the bottom thread has a sending queue, that is it sends all messages to an additional thread that emits the final messages. - Draw the new message exchanges - Is causal ordering still ensured? - FIFO ?
![Page 52: Asynchronous Components -](https://reader033.vdocuments.site/reader033/viewer/2022060702/62975a0420e4b5312b0aacaa/html5/thumbnails/52.jpg)
Exercise 5: Ensuring causal ordering with many sending queues
• Same thing but with one sending queue per destination process - Draw the new message exchanges - Is causal ordering still ensured? - FIFO ?