Two implementations of the
threads library are available, depending
on the capabilities of the operating system:
-
System threads. This implementation builds on the OS-provided threads
facilities: POSIX 1003.1c threads for Unix, and Win32 threads for
Windows. When available, system threads support both bytecode and
native-code programs.
- VM-level threads. This implementation performs time-sharing and
context switching at the level of the OCaml virtual machine (bytecode
interpreter). It is available on Unix systems, and supports only
bytecode programs. It cannot be used with native-code programs.
Programs that use system threads must be linked as follows:
ocamlc -thread other options threads.cma other files
ocamlopt -thread other options threads.cmxa other files
All object files on the command line must also have been compiled with
the
-thread option (see chapter
8).
Programs that use VM-level threads must be compiled with the
-vmthread
option to
ocamlc (see chapter
8), and be linked as follows:
ocamlc -vmthread other options threads.cma other files