caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Charles 'Buck' Krasic" <krasic@acm.org>
To: caml-list@inria.fr
Subject: [Caml-list] interfacing C threads with OCaml
Date: Tue, 5 Jun 2001 13:04:01 -0700	[thread overview]
Message-ID: <200106052004.f55K41r27032@hamilton.cse.ogi.edu> (raw)


Hi,

I have a C program that contains a library implemented in OCaml
(native compilation).  The library glued to C using the techniques
described in Chapter 17 of the OCaml manual.

The overall program implements a pipeline of producer-consumer
functions, one of which is implemented in OCaml.  (The pipeline
implements an adaptive MPEG video player).  Each such function is an
infinite loop which alternates between produce and consume operations.
The OCaml one calls out to C primitives that do produce and consume
operations.  These primitives do marshalling between C datatypes and
OCaml.

It all works fine for a single pipeline, but I would like to support
concurrent pipelines where each pipeline is implemented by a separate
system thread (Linux pthreads).  

My OCaml pipeline function does a segmentation fault when I do this.
I have built the OCaml code using the -thread flag, and my link step
does -lthreadsnat.  I understand that the OCaml runtime is not
thread-safe, but I got the impression is that using -thread causes it
to use a single master lock, which is released when calling out to C
code; making it safe to mix threaded-C with OCaml.

Is this incorrect?

Are the marshalling macros in Chapter 17 (Store_field, etc.) safe wrt
the OCaml master lock?  

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


             reply	other threads:[~2001-06-06 20:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-05 20:04 Charles 'Buck' Krasic [this message]
2001-06-12 14:55 ` Xavier Leroy

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=200106052004.f55K41r27032@hamilton.cse.ogi.edu \
    --to=krasic@acm.org \
    --cc=caml-list@inria.fr \
    /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).