Download presentation
Presentation is loading. Please wait.
1
Using a simple Rendez-Vous mechanism in Java
João Duarte
2
Motivation Real time programs
Cooperating threads sharing the same context (data structures, IO devices, etc.) Need for interaction
3
Interaction Interaction primitives: Structured interaction mechanisms:
Locks Semaphores Structured interaction mechanisms: Rendez-Vous (ADA) Monitors (Java)
4
Java Monitors Monitor: passive object providing synchronized methods
Dynamic model of Java multithreading computation: Dynamic set of monitors Dynamic set of threads Threads interact indirectly through monitor services calls. Direct interaction of threads was suppressed for safety reasons (e.g. functions resume() and suspend() not supported after JDK 1.3) atomically executed services that can be called from threads.
5
ADA’s Rendez-Vous Common execution of a code section by two threads (tasks) Asymmetric, “roles” of both tasks are different: The client calls rendezvous (and needs “to know” the partner) The server accepts rendezvous (and does not need to know the client) Synchronous, the first task reaching the rendezvous point waits for its partner
6
ADA’s Rendez-Vous Data of both “actors” of rendezvous can be used within the execution Every transformation of tasks data can be programmed (and atomically executed) as a rendezvous Dynamic model of Ada multithreading computation: Set of tasks that interact directly using the rendezvous mechanism
7
ADA’s Rendez-Vous - Server Example
Initialization of Entries Beginning of task Store first Item
8
ADA’s Rendez-Vous - Server Example
Select statement with two alternatives
9
ADA’s Rendez-Vous – Client Example
Create the Task Acess as a normal variable
10
Using ADA’s Rendez-Vous in Java – Why?
Allows “pure monitor” (i.e. server) thread. More general model of parallel (concurrent) computation. An easy way how to synchronize two threads in a specified point of their execution and join data exchange/transformation. Asymetric allows pure monitor.. Direct interaction of threads -> more general model
11
Using ADA’s Rendez-Vous in Java – Why?
A way how to construct threads with “two faces”, i.e. part of their life they can act as clients and another part as servers A way how to construct multiple-mode monitors, e.g. monitors that provides various sets of services within various stages of their life.
12
Implementing Rendez-Vous in Java - Keypoints
As simple as possible,no need to include all the facilities of the Ada rendezvous implementation No need for any special JVM or pre-processor Construct an object type whose instance can manage an entry synchronization (i.e. to every single entry should be assigned one synchronization object). Simple -> all the possibilities of the select statement
13
Implementing Rendez-Vous in Java - Keypoints
Methods of a dedicated synchronization object should be called only from the server side of rendezvous. To call an entry from the client side should be as simple as the Java conventional public method call It is necessary to implement a simple form of the Ada select statement Rendezvous implementation is invisible for the client
14
Implementing Rendez-Vous in Java – State Machine
15
Implementing Rendez-Vous in Java – Entry class
16
Implementing Rendez-Vous in Java – Entry class
17
Implementing Rendez-Vous in Java – Entry class
18
Using the Entry class Uses Entry e1 Both use Entry e2
Code executed inside the Rendez Vous Methods called by the client Both use Entry e2
19
Using the Entry class here it accepts only entry_1() call
it accepts either entry_21() or entry_22() call A simple form of Ada-like select statement can be easily implemented when a group of entries uses the same synchronization object. it can call entry of another server as well
20
Conclusion Simple and easy to use Just one class needed
Extends possibilities on how to design Java multithreaded program architecture
21
Future work Add EntrySet class
Include all the possibilities of the select statement: Boolean guards Delays else alternative
22
Web Source code and examples:
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.