Presentation is loading. Please wait.

Presentation is loading. Please wait.

J-O-Caml (6) pauillac.inria.fr/~levy/qinghua/j-o-caml Qinghua, December 4.

Similar presentations


Presentation on theme: "J-O-Caml (6) pauillac.inria.fr/~levy/qinghua/j-o-caml Qinghua, December 4."— Presentation transcript:

1 J-O-Caml (6) jean-jacques.levy@inria.fr pauillac.inria.fr/~levy/qinghua/j-o-caml Qinghua, December 4

2 Plan of this class concurrency threads, locks, conditions, shared memory communication channels, CML distributed setting principles of Jocaml a concurrent labeling program ?!!!

3 Exercices ???

4 Threads light weight processes are implemented in Thread module both VM threads (byte code) and Linux threads (binary if available) produces

5 Concurrency - Shared memory critical sections -- locks

6 Concurrency - Shared memory concurrent FIFO with locks + condition variables

7 Concurrency - Shared memory locks and condition variables are light implementations of old Hoare/Hansen/Dijkstra monitors implemented in many languages with shared memory [Modula3, C#] curiously missing in Java [locks but no conditions !] impossible to write correct version of readers/writers without them

8 Communication channels John Reppy’s Event module for CML (SML/NJ) in Ocaml

9 Distributed environments asynchronous communications rendez-vous on unlocalized channels are impossible because of distributed consensus need for join patterns

10 Join-Patterns asynchronous channels

11 Join-Patterns synchronous channels join patterns [waiting for presence of several messages]

12 Join-Patterns actors without memory state ! half of J.-P. Banatre multi-functions paradigm hiding internal channels

13 Join-Patterns collectors are frequent programming scheme example of a compute server

14 Distribution server side (with help of nameserver) on here.inria.fr client side (with help of nameserver)

15 Real examples ray tracers (given in standard jocaml release) one of which won the ICFP programming contest slight modifications to get the concurrent or distributed version join patterns are polyphonic C# (Benton), VB 9.0 (Russo) Jocaml [without mobility] now follows Ocaml releases and mobility ? General philosophy concurrent programming is very hard distribution is impossible to debug local and remote behaviors should be identical

16 Combien d’objets dans une image? Jean-Jacques Lévy INRIA

17 Labeling 16 objects in this picture 1 1 2 3 45 6 7 8 9 10 11 12 1314

18 Concurrent algorithm 1) first pass - scan pixels left-to-right, top-to-bottom giving a new object id each time a new object is met, can be done on dual-core with half image per core. second pass - generate equivalences between ids due to new adjacent relations met during scan of pixels, taking care of border (generating new equivalences) third pass - compute the number of equivalence classes and give result in parallel think of the distributed setting with several machines on the net


Download ppt "J-O-Caml (6) pauillac.inria.fr/~levy/qinghua/j-o-caml Qinghua, December 4."

Similar presentations


Ads by Google