diff options
20 files changed, 19 insertions, 20 deletions
diff --git a/psr-SystemeReseaux-Projet.tar.gz b/psr-SystemeReseaux-Projet.tar.gz Binary files differnew file mode 100644 index 0000000..525dc75 --- /dev/null +++ b/psr-SystemeReseaux-Projet.tar.gz diff --git a/screens/2014-05-25-011028_1366x768_scrot.png b/screens/2014-05-25-011028_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..3663ce3 --- /dev/null +++ b/screens/2014-05-25-011028_1366x768_scrot.png diff --git a/screens/2014-05-25-011059_1366x768_scrot.png b/screens/2014-05-25-011059_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..0f601d1 --- /dev/null +++ b/screens/2014-05-25-011059_1366x768_scrot.png diff --git a/screens/2014-05-25-011138_1366x768_scrot.png b/screens/2014-05-25-011138_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..e04ee64 --- /dev/null +++ b/screens/2014-05-25-011138_1366x768_scrot.png diff --git a/screens/2014-05-25-011223_1366x768_scrot.png b/screens/2014-05-25-011223_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..8d99b50 --- /dev/null +++ b/screens/2014-05-25-011223_1366x768_scrot.png diff --git a/screens/2014-05-25-012431_1366x768_scrot.png b/screens/2014-05-25-012431_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..7f36b31 --- /dev/null +++ b/screens/2014-05-25-012431_1366x768_scrot.png diff --git a/screens/2014-05-25-012551_1366x768_scrot.png b/screens/2014-05-25-012551_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..91b37b2 --- /dev/null +++ b/screens/2014-05-25-012551_1366x768_scrot.png diff --git a/screens/2014-05-25-012814_1366x768_scrot.png b/screens/2014-05-25-012814_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..9be7275 --- /dev/null +++ b/screens/2014-05-25-012814_1366x768_scrot.png diff --git a/screens/2014-05-25-012903_1366x768_scrot.png b/screens/2014-05-25-012903_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..27e53d6 --- /dev/null +++ b/screens/2014-05-25-012903_1366x768_scrot.png diff --git a/screens/2014-05-25-012958_1366x768_scrot.png b/screens/2014-05-25-012958_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..845e91d --- /dev/null +++ b/screens/2014-05-25-012958_1366x768_scrot.png diff --git a/screens/2014-05-25-013408_1366x768_scrot.png b/screens/2014-05-25-013408_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..4110bfd --- /dev/null +++ b/screens/2014-05-25-013408_1366x768_scrot.png diff --git a/screens/2014-05-25-013506_1366x768_scrot.png b/screens/2014-05-25-013506_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..2fd7e39 --- /dev/null +++ b/screens/2014-05-25-013506_1366x768_scrot.png diff --git a/screens/2014-05-25-122207_1366x768_scrot.png b/screens/2014-05-25-122207_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..b603873 --- /dev/null +++ b/screens/2014-05-25-122207_1366x768_scrot.png diff --git a/screens/2014-05-25-122907_1366x768_scrot.png b/screens/2014-05-25-122907_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..14878d8 --- /dev/null +++ b/screens/2014-05-25-122907_1366x768_scrot.png diff --git a/screens/2014-05-25-123109_1366x768_scrot.png b/screens/2014-05-25-123109_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..a4e5a8d --- /dev/null +++ b/screens/2014-05-25-123109_1366x768_scrot.png diff --git a/screens/2014-05-25-123122_1366x768_scrot.png b/screens/2014-05-25-123122_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..f452230 --- /dev/null +++ b/screens/2014-05-25-123122_1366x768_scrot.png diff --git a/screens/2014-05-25-123135_1366x768_scrot.png b/screens/2014-05-25-123135_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..651b861 --- /dev/null +++ b/screens/2014-05-25-123135_1366x768_scrot.png diff --git a/screens/2014-05-25-224448_1366x768_scrot.png b/screens/2014-05-25-224448_1366x768_scrot.png Binary files differnew file mode 100644 index 0000000..0f53fa6 --- /dev/null +++ b/screens/2014-05-25-224448_1366x768_scrot.png diff --git a/src/kahn_pipe.ml b/src/kahn_pipe.ml index 2df8bc5..6e467ab 100644 --- a/src/kahn_pipe.ml +++ b/src/kahn_pipe.ml @@ -6,12 +6,11 @@ module Pipe: S = struct type 'a in_port = in_channel type 'a out_port = out_channel - let new_channel = - fun () -> + let new_channel () = let i, o = Unix.pipe () in Unix.in_channel_of_descr i, Unix.out_channel_of_descr o - let get (c : 'a in_port) : 'a = + let get c = fun () -> Marshal.from_channel c let put x c = @@ -60,17 +59,16 @@ module Pipe: S = struct let doco l = fun () -> - let children = - List.map - (fun p -> - match Unix.fork () with - | 0 -> - run p; - exit 0 - | i -> i) - l - in - List.iter + let launch p = + let pid = Unix.fork() in + if pid = 0 then begin + run p; + exit 0 + end else + pid + in + let children = List.map launch l in + List.iter (fun i -> try ignore(Unix.waitpid [] i) with _ -> ()) children end diff --git a/src/primes.ml b/src/primes.ml index 6975b9e..c5a1831 100644 --- a/src/primes.ml +++ b/src/primes.ml @@ -28,20 +28,21 @@ module Primes (K : Kahn.S) = struct (get qi) >>= (fun v -> if v <> -1 then begin - K.output @@ Format.sprintf "%d@." v; - (delay new_channel ()) >>= - (fun (qi2, qo2) -> doco [ filter v qi qo2 ; primes qi2 ]) + K.output (string_of_int v ^ "\n"); + let qi2, qo2 = new_channel () in + doco [ filter v qi qo2 ; primes qi2 ] end else return ()) let main : int process = - (delay new_channel ()) >>= - (fun (q_in, q_out) -> doco [ integers 2000 q_out ; primes q_in ]) + (return ()) >>= + (fun () -> let q_in, q_out = new_channel () in + doco [ integers 10000 q_out ; primes q_in ]) >>= (fun () -> return 42) end -module Eng = Kahn_seq.Seq +module Eng = Kahn_pipe.Pipe module P = Primes(Eng) let () = |