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
Re: [Caml-list] native threads not parallel?
[ 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@k...>
Subject: Re: [Caml-list] native threads not parallel?
From: Shivkumar Chandrasekaran <>

> not. But I seem to have the same problem as discussed by Markus Mottl 
> (see attachment below) on Mac OS X 10.2.4 on a dual processor G4 
> machine. An earlier message in that thread mentioned that there was no 
> such problem on dual-processor Linux machines.

Let's answer again, since this is a frequent question: ocaml threads
do not not support parrallelism. Only one ocaml thread will run at a
time, independently of the number of processors, and this on any

> > From :Markus Mottl < >
> > The only thing I can imagine is that OCaml somehow changes
> > scheduling so that the threads cannot run in parallel anymore, even if
> > "enter_blocking_section" is used. Is this possible? Or am I just making
> > some stupid mistake?

enter_blocking_section only happens in C code, and is followed by a
leave_blocking_section before returning to caml code. Since the
leave_blocking_section reacquires the lock, no more than one ocaml
thread can run simultaneously.
Easy way to crash the runtime: call a caml callback immediately after
an enter_blocking_section.  The two caml threads will start to
allocate simultaneously on the same heap, without any locking...

Jacques Garrigue
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: