From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id BB1AA7EF10 for ; Mon, 9 Mar 2015 08:36:36 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of dra-news@metastack.com) identity=pra; client-ip=62.13.148.100; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dra-news@metastack.com"; x-sender="dra-news@metastack.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of dra-news@metastack.com designates 62.13.148.100 as permitted sender) identity=mailfrom; client-ip=62.13.148.100; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dra-news@metastack.com"; x-sender="dra-news@metastack.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@outmail148100.authsmtp.co.uk) identity=helo; client-ip=62.13.148.100; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dra-news@metastack.com"; x-sender="postmaster@outmail148100.authsmtp.co.uk"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BZAAAeTP1Ul2SUDT5ZgmR0WgEDr0cGkniFcAKBJk0BAQEBAQEQAQEBAQEIFgdChA8BAQEEAzdPAgEIGAoUEDIlAgQbiCgDCcM3IIYKhQ2EPTiDF4EWBZNzghqDVQGBGTmCb48yhBFvAYFDfwEBAQ X-IPAS-Result: A0BZAAAeTP1Ul2SUDT5ZgmR0WgEDr0cGkniFcAKBJk0BAQEBAQEQAQEBAQEIFgdChA8BAQEEAzdPAgEIGAoUEDIlAgQbiCgDCcM3IIYKhQ2EPTiDF4EWBZNzghqDVQGBGTmCb48yhBFvAYFDfwEBAQ X-IronPort-AV: E=Sophos;i="5.11,366,1422918000"; d="scan'208";a="102557264" Received: from outmail148100.authsmtp.co.uk ([62.13.148.100]) by mail3-smtp-sop.national.inria.fr with ESMTP; 09 Mar 2015 08:36:35 +0100 Received: from mail-c237.authsmtp.com (mail-c237.authsmtp.com [62.13.128.237]) by punt15.authsmtp.com (8.14.2/8.14.2/) with ESMTP id t297aYdu023967 for ; Mon, 9 Mar 2015 07:36:34 GMT Received: from romulus.metastack.com (cpc1-cmbg5-0-0-cust241.5-4.cable.virginm.net [81.98.252.242]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/) with ESMTP id t297aYGj093433 for ; Mon, 9 Mar 2015 07:36:34 GMT Received: from remus.metastack.local (remus.metastack.com [172.16.0.1]) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id t297aXAL000954 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL) for ; Mon, 9 Mar 2015 07:36:33 GMT Received: from Remus.metastack.local ([fe80::547c:3c42:e1da:eda2]) by Remus.metastack.local ([fe80::547c:3c42:e1da:eda2%10]) with mapi id 14.03.0224.002; Mon, 9 Mar 2015 07:36:33 +0000 From: David Allsopp To: "OCaml List (caml-list@inria.fr)" Thread-Topic: [Caml-list] C function calls OCaml function in multithreads Thread-Index: AQHQVuyRv/Qh8/2LtEee9pEaqumFP50TY6CAgABjwbA= Date: Mon, 9 Mar 2015 07:36:31 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.0.18] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Organization: MetaStack Solutions Ltd. X-Scanned-By: MIMEDefang 2.65 on 172.16.0.20 X-Server-Quench: 031a25fa-c62f-11e4-9f74-002590a135d3 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCd1ZAARAlZZVg1f DC4bFwdFRBksPQFF ChxFJgxfNlEAUAAU NkdBMnJSNkcdTBdX QSgLUkspAR9uW2N0 bhpRag9eZEBNW0ti UVZASkxQEQd2AxgD GRwbTRk8MwdPfy8Z EhxiV3NfX0c0d0J9 RwBUFmxXZ2I2OX1M VkIOagJVJQdXd0lC bk1/VHEIaGVWZ3ll E1QlBR1jdQZ0ISFR BwUMNk4nCW1DECM6 TAwDGjNnFkQBQz57 CDcvL1pUElsXOVkz Nl1pWFRQNgIWFgxC H1tACSNCTwAA X-Authentic-SMTP: 61633634383431.1024:706 X-AuthFastPath: 0 (Was 255) X-AuthSMTP-Origin: 81.98.252.242/25 X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system. Subject: RE: [Caml-list] C function calls OCaml function in multithreads Masateru Kawaguchi wrote: > I sent a question to caml-list a few days ago, but there is no reply yet. > So let me explain my question in detail. > > I have a C program and I'll try to rewrite some libraries of them in OCam= l. > The C program runs in multithreads, so the OCaml library will be called b= y multithread. > In order to avoid two threads running the OCaml part at one time, I'll tr= y insert > a code to acquire mutex lock in the C function before calling the OCaml f= unction. > But I'm not sure that is enough to run the program safely. > > Does anyone know about it ? > Please give me some advise about multithreading or how to incorporate OCa= ml into C program. Chapter 19 of the manual? Especially sections 10 "Advanced topics: multithr= eading" (http://caml.inria.fr/pub/docs/manual-ocaml/intfc.html#sec465) and = 7 "Advanced topics: callbacks from C to OCaml" (http://caml.inria.fr/pub/do= cs/manual-ocaml/intfc.html#sec448 - see in particular 19.7.4) David