/ Published in: Other

this example checks that when the context switch occurs in the O'Caml runtime. compile it with:
- ocamlc -vmthread -I +threads -I unix unix.cmxa threads.cmxa filename.ml
- ocamlc -thread -I +threads -I unix unix.cmxa threads.cmxa filename.ml
- ocamlopt -thread -I +threads -I unix unix.cmxa threads.cmxa filename.ml
both 1. and 2. terminates, while 3. not (on my OCaml 3.11.1, on Mac OS X).
See also:http://snipplr.com/view/19509/
Expand |
Embed | Plain Text
let allocation _ = ignore (String.create 100000) let r = ref false;; let rec forever x = allocation (); r:=true; forever x;; let rec wait _ = if !r then print_string "end.\n" else (allocation (); wait ()) ;; Thread.create (fun _ -> forever ()) ();; wait ();; (* blocks forever if we comment out both occurrence of `allocation' *)
Comments

You need to login to post a comment.
the 8 best power strip floor cover http://bestpowerstrips.com/top/the-8-best-power-strip-floor-cover-1059