caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] External C functions
@ 2001-05-08  3:29 Ravi Chamarty
  2001-05-09  1:35 ` Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: Ravi Chamarty @ 2001-05-08  3:29 UTC (permalink / raw)
  To: caml-list


Hi,

 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. 

Thanks,
Any help would be highly appreciated,
Ravi
 


----------------------------------------------------------
Ravi S Chamarty                    E-mail: ravi@ittc.ku.edu
Graduate Research Assistant,       Voice :785-864-7799 
ITTC,2335 Irving Hill Road,                
University of Kansas,
Lawrence KS 66045-7612


-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] External C functions
  2001-05-08  3:29 [Caml-list] External C functions Ravi Chamarty
@ 2001-05-09  1:35 ` Jacques Garrigue
  0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2001-05-09  1:35 UTC (permalink / raw)
  To: ravi; +Cc: caml-list

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-05-09  1:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-08  3:29 [Caml-list] External C functions Ravi Chamarty
2001-05-09  1:35 ` Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).