[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jacques Garrigue <garrigue@k...> |
| Subject: | Re: [Caml-list] External C functions |
From: Ravi Chamarty <ravi@ittc.ukans.edu> > I would like to use a C library which has a number of Pthread operations > used in it. What would be the limitations of the Caml system if I write a > wrapper around it's API ? These wrappers would be using the API provided > by the C library. The C library threads interact among one another. Are > there any special concerns I should be aware of ? > > Specifically, I would be interested in knowing if I could run and > schedule two or more threads within the C system. Having multiple threads within the C system is not a problem at all. For instance we linked the mozilla widget inside a Caml program, itself using native threads, and this worked OK. The only constraint proper to Caml is that no more than one Caml thread can be running at once, but this does not affect pure C threads. However, one has to be careful about callbacks: if a Caml callback is called from a C thread, and this C thread is not the thread which was called from Caml, then the callback will only run after the original thread gives the control back to Caml. This is then very easy to deadlock. Worse, if your Caml program isn't compiled with threads, there is no locking involved, and you end up running two Caml thread simultaneously, for an happy crash. Cheers, --------------------------------------------------------------------------- Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp <A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/>JG</A> ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr