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 (08:46)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] vm threads
From: Ian Zimmerman <>

> 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.

That's even stronger than that: if you do not plan to run some pure C
threads concurently with ocaml, you usually don't need any
synchronization, either for system or VM threads.
With VM threads, you may only change thread when executing ocaml code,
so all your C code is single-threaded.
With system threads, you have to release the ocaml lock by calling
enter_blocking_section before any other ocaml thread may run.
If you don't want to be interrupted, just don't release it.
So you don't need to bother with synchronization as long as you don't
introduce concurrency intentionally on the C side. (But this might be
what you intend to do...)

Jacques Garrigue