caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: ravi@ittc.ukans.edu
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] External C functions
Date: Wed, 09 May 2001 10:35:14 +0900	[thread overview]
Message-ID: <20010509103514Y.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <Pine.LNX.4.10.10105072220320.826-100000@elroy.ittc.ukans.edu>

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


      reply	other threads:[~2001-05-09  1:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-08  3:29 Ravi Chamarty
2001-05-09  1:35 ` Jacques Garrigue [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010509103514Y.garrigue@kurims.kyoto-u.ac.jp \
    --to=garrigue@kurims.kyoto-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=ravi@ittc.ukans.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).