From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA17335; Wed, 6 Jun 2001 22:54:09 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA17310 for caml-list@pauillac.inria.fr; Wed, 6 Jun 2001 22:54:08 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA19449 for ; Tue, 5 Jun 2001 22:04:07 +0200 (MET DST) Received: from hamilton.cse.ogi.edu (c360746-a.bvrtn1.or.home.com [24.16.210.116]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f55K46r14664 for ; Tue, 5 Jun 2001 22:04:06 +0200 (MET DST) Received: (from krasic@localhost) by hamilton.cse.ogi.edu (8.11.2/8.11.2) id f55K41r27032; Tue, 5 Jun 2001 13:04:01 -0700 Date: Tue, 5 Jun 2001 13:04:01 -0700 Message-Id: <200106052004.f55K41r27032@hamilton.cse.ogi.edu> From: "Charles 'Buck' Krasic" To: caml-list@inria.fr Subject: [Caml-list] interfacing C threads with OCaml User-Agent: SEMI/1.13.7 (Awazu) CLIME/1.13.6 (=?ISO-2022-JP?B?GyRCQ2YbKEI=?= =?ISO-2022-JP?B?GyRCJU4+MRsoQg==?=) MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386-redhat-linux) MIME-Version: 1.0 (generated by SEMI 1.13.7 - "Awazu") Content-Type: text/plain; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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