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: Ian Zimmerman <itz@b...>
Subject: Re: [Caml-list] vm threads

Ian> Are Ocaml's VM threads preemptive?  That is, does the virtual
Ian> machine actually have a timer and give a slice to each thread?  Or
Ian> does a thread run until it's blocked?

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

The reason I asked was: when writing a library that uses C extension
code and a global data structure in the C code, can I just use system
thread primitives for synchronization (that would be pthreads since
I am only thinking about Unix type systems at least ATM) and not worry
about VM threads?

>From your post the answer seems to be yes.

-- 
"It's not true or not."  A reality show producer (real quote)