~ubuntu-branches/debian/sid/ocaml/sid

« back to all changes in this revision

Viewing changes to testsuite/tests/lib-systhreads/testfork.ml

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu
  • Date: 2011-04-21 21:35:08 UTC
  • mfrom: (1.1.11 upstream) (12.1.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110421213508-kg34453aqmb0moha
* Fixes related to -output-obj with g++ (in debian/patches):
  - add Declare-primitive-name-table-as-const-char
  - add Avoid-multiple-declarations-in-generated-.c-files-in
  - fix Embed-bytecode-in-C-object-when-using-custom: the closing
    brace for extern "C" { ... } was missing in some cases

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(* POSIX threads and fork() *)
 
2
 
 
3
let compute_thread c = ignore c
 
4
(*
 
5
  while true do 
 
6
    print_char c; flush stdout;
 
7
    for i = 1 to 100000 do ignore(ref []) done
 
8
  done
 
9
*)
 
10
 
 
11
let main () =
 
12
  ignore(Thread.create compute_thread '1');
 
13
  Thread.delay 1.0;
 
14
  print_string "Forking..."; print_newline();
 
15
  match Unix.fork() with
 
16
  | 0 ->
 
17
      print_string "In child..."; print_newline();
 
18
      Gc.minor();
 
19
      print_string "Child did minor GC."; print_newline();
 
20
      ignore(Thread.create compute_thread '2');
 
21
      Thread.delay 1.0;
 
22
      print_string "Child is exiting."; print_newline();
 
23
      exit 0
 
24
  | pid ->
 
25
      print_string "In parent..."; print_newline();
 
26
      Thread.delay 2.0;
 
27
      print_string "Parent is exiting."; print_newline();
 
28
      exit 0
 
29
 
 
30
let _ = main()
 
31
 
 
32