Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
vm threads
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-10-15 (05:23)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] vm threads
> Are Ocaml's VM threads preemptive?  That is, does the virtual machine 
> actually have a timer and give a slice to each thread?  Or does a thread
> run until it's blocked?

The timer signal is used, so they are preemptive.
This is however only true for threads running ocaml code.
There is no way to switch thread during C calls, so that all
potentially blocking C calls should be manually converted to
non-blocking ones (this is already done for the standard library and
the Unix module.)
This can also create problems when somebody else needs the timer
signal (for instance the Graphics module.)

System threads are most costly (they use system resources), but they
simplify greatly working with C.

     Jacques Garrigue