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
Question about ocaml threads and TLS (on linux)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-02-25 (07:26)
From: Goswin von Brederlow <goswin-v-b@w...>
Subject: Re: [Caml-list] Question about ocaml threads and TLS (on linux)
Philippe Wang <> writes:

> Hi,
> I'm not sure I understand (though I've read the whole text), but maybe
> this will answer your question:
> On Linux, OCaml threads (with the native compiler "ocamlopt") are
> implemented with POSIX threads (in C), so when your OCaml thread runs
> the C stub, it's the same as if you were running the C stub in some C
> thread.

How about bytecode?

> When you are in a section declared as a blocking section, a collection
> can be triggered concurrently in another thread and so the heap must
> not be accessed neither for reading or writing, that's all.
> Using __thread recent feature should also work if you manage to
> compile everything correctly. Notably, we use it in some places in
> ocaml4multicore (a patch to ocaml's runtime library to allow parallel
> threads). However, I don't know how __thread is handled by the
> compiler... I mean : it there a pointer for buf in every thread or
> only in those that use it?

Only in those that use it. But that will be multiple threads. In those
that don't use it 4/8 bytes will be wasted.

> I hope my answer isn't useless!
> Cheers,