ReactiveML and JoCaml: two concurrent extensions of OCaml Louis - - PowerPoint PPT Presentation

reactiveml and jocaml two concurrent extensions of ocaml
SMART_READER_LITE
LIVE PREVIEW

ReactiveML and JoCaml: two concurrent extensions of OCaml Louis - - PowerPoint PPT Presentation

ReactiveML and JoCaml: two concurrent extensions of OCaml Louis Mandel louis.mandel@lri.fr Laboratoire de Recherche en Informatique Universit e Paris-Sud 11 Synchron08 03/12/2008 Programming of concurrent systems General purpose


slide-1
SLIDE 1

ReactiveML and JoCaml: two concurrent extensions of OCaml

Louis Mandel louis.mandel@lri.fr Laboratoire de Recherche en Informatique Universit´ e Paris-Sud 11 Synchron’08 – 03/12/2008

slide-2
SLIDE 2

Programming of concurrent systems

General purpose programming language + dedicated constructs Two experiments above Ocaml:

Synchronous: ReactiveML

based on the synchronous reactive model of Boussinot Programming systems with a lot of concurrence, communication and synchronisation Interests: determinism, compositionnality, safety

Asynchronous: JoCaml (Luc Maranget)

Based on the join-calculus Programming of distributed systems Interests: parallel execution

2/21

slide-3
SLIDE 3

ReactiveML

slide-4
SLIDE 4

killable

signal kill val kill : (int, int list) event let process killable p = let id = gen_id () in print_endline ("["^(string_of_int id)^"]"); do run p until kill(ids) when List.mem id ids done val killable : unit process -> unit process

4/21

slide-5
SLIDE 5

Dynamic creation: reminder

let rec process extend to_add = await to_add(p) in run p || run (extend to_add) val extend : (’a, ’b process) event -> unit process signal to_add default process () gather (fun p q -> process (run p || run q)) val add_to_me : (unit process, unit process) event

5/21

slide-6
SLIDE 6

Dynamic creation with state

let rec process extend to_add state = await to_add(p) in run (p state) || run (extend to_add state) val extend : (’a , (’b -> ’c process)) event -> ’b -> unit process signal to_add default (fun s -> process ()) gather (fun p q s -> process (run (p s) || run (q s))) val to_add : ((’_state -> unit process) , (’_state -> unit process)) event

6/21

slide-7
SLIDE 7

extensible

signal add val add : ((int * (state -> unit process)), (int * (state -> unit process)) list) event let process extensible p_init state = let id = gen_id () in print_endline ("{"^(string_of_int id)^"}"); signal add_to_me default (fun s -> process ()) gather (fun p q s -> process (run (p s) || run (q s))) in run (p_init state) || run (extend add_to_me state) || loop await add(ids) in List.iter (fun (x,p) -> if x = id then emit add_to_me p) ids end val extensible : (state -> ’a process) -> state -> unit process

7/21

slide-8
SLIDE 8

JoCaml

slide-9
SLIDE 9

JoCaml: one place buffer

let create () = def some(v) & get() = none() & reply v to get

  • r none() & put(v) = some(v) & reply () to put

in spawn none() ; (* buffer initially empty *) (put, get)

9/21

slide-10
SLIDE 10

JoCaml: infinite buffer

let create () = def state(xs,y::ys) & get() = state(xs,ys) & reply y to get

  • r state(xs,ys) & put(x) =

state(x::xs,ys) & reply () to put

  • r state(_::_ as xs,[]) & get() =

state([],List.rev xs) & reply get() to get in spawn state([],[]) ; (* buffer initially empty *) (put, get)

10/21

slide-11
SLIDE 11

Boids

Simulation of a flock of birds, a school of fish . . . Main points:

  • ReactiveML and JoCaml collaboration
  • centralized and distributed execution
  • channels mobility, dynamic aspects
  • failure detection, timeout

11/21

slide-12
SLIDE 12

Boids

floflo server machiavel 12/21

slide-13
SLIDE 13

Boids

1/[] boids 1 floflo server machiavel 13/21

slide-14
SLIDE 14

Boids

2/[1] boids 2 boids 1 floflo server machiavel 14/21

slide-15
SLIDE 15

Boids

boids 2 boids 1 floflo server machiavel 15/21

slide-16
SLIDE 16

Boids

3/[1;2] boids 3 boids 2 boids 1 floflo server machiavel 16/21

slide-17
SLIDE 17

Boids

boids 3 boids 2 boids 1 floflo server machiavel 17/21

slide-18
SLIDE 18

Boids

boids 3 boids 1 floflo server machiavel 18/21

slide-19
SLIDE 19

Boids

4/[1;3] boids 4 boids 3 boids 1 floflo server machiavel 19/21

slide-20
SLIDE 20

Boids

boids 4 boids 3 boids 1 floflo server machiavel 20/21

slide-21
SLIDE 21

Implementations are Available

http://rml.lri.fr http://jocaml.inria.fr

21/21

slide-22
SLIDE 22

Asynchronous Communication

let new_cell () = def state (_) & set(x) = state(Some x) & reply () to set

  • r state (Some x) & get() = state(None) & reply x to get in

spawn (state None); (set, get) val new_cell : (’a -> unit process, unit -> ’a process) let set_step, get_step = new_cell() let process generate_step = loop let n = run (get_step ()) in emit step n ; pause end

22/21

slide-23
SLIDE 23

23/21