Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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