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
[Caml-list] C callbacks and threading...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-09-27 (13:20)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] C callbacks and threading...
> The manual says a caml function can be registered and then used from
> the C runtime. Is this still true if called from a thread not
> created from within Caml ie. via the Thread module? I have vague
> recollections of caml's thread system involving some bookkeeping
> which probably rules this usage out.

It should work if:
- the Caml code doesn't use threads itself;
- you call it via callback_exn rather than callback (to make sure you
  always get control back from the Caml code);
- you protect the call to callback_exn by a mutex, to make sure that
  no two threads can call into Caml simultaneously.

In all other cases, and especially if the Caml code is multithreaded,
you would probably break something in the Caml runtime system.

- Xavier Leroy
Bug reports:  FAQ:
To unsubscribe, mail  Archives: