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 82EEF7EF10 for ; Mon, 9 Mar 2015 10:43:18 +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.98; 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.98 as permitted sender) identity=mailfrom; client-ip=62.13.148.98; 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@outmail148098.authsmtp.com) identity=helo; client-ip=62.13.148.98; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dra-news@metastack.com"; x-sender="postmaster@outmail148098.authsmtp.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BZAAD4av1Ul2KUDT5bgmR0WgEDr1MGkniFcAKBKE0BAQEBAQEQAQEBAQEIFgdChA8BAQEEA4EGAgEIGAokMiUCBBuIKAMJwyMghgqFDYQ9OIMXgRYFijuJOIVvAYEZOYVDiRyDQoQRbwGBQ38BAQE X-IPAS-Result: A0BZAAD4av1Ul2KUDT5bgmR0WgEDr1MGkniFcAKBKE0BAQEBAQEQAQEBAQEIFgdChA8BAQEEA4EGAgEIGAokMiUCBBuIKAMJwyMghgqFDYQ9OIMXgRYFijuJOIVvAYEZOYVDiRyDQoQRbwGBQ38BAQE X-IronPort-AV: E=Sophos;i="5.11,366,1422918000"; d="scan'208";a="102577706" Received: from outmail148098.authsmtp.com ([62.13.148.98]) by mail3-smtp-sop.national.inria.fr with ESMTP; 09 Mar 2015 10:43:17 +0100 Received: from mail-c235.authsmtp.com (mail-c235.authsmtp.com [62.13.128.235]) by punt17.authsmtp.com (8.14.2/8.14.2/) with ESMTP id t299hFC6066796 for ; Mon, 9 Mar 2015 09:43:15 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 t299hB4M066683 for ; Mon, 9 Mar 2015 09:43:11 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 t299hArc001556 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL) for ; Mon, 9 Mar 2015 09:43:11 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 09:43:10 +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/2LtEee9pEaqumFP50TY6CAgABjwbCAAB+GAIAAA7iQ Date: Mon, 9 Mar 2015 09:43:10 +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="iso-8859-1" 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: b36e5cb4-c640-11e4-b396-002590a15da7 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCd1ZAARAlZZVg1f DC4bFwdFRBksPQFF ChxFJgxfNlEAUAAU NkdBMnJSNkcdTBdX QSgLUkspAR9uW2N0 bhpRZA9ZYUBPXkti UVZASkxQEQd2AxgD GRwbTRk8MwdPcSYC YTtiWHZdVEc0d0J5 QgAGFmtTYDQybH1M VkRYagJVJQdXLBxM bE1/VHEIaGVWZ380 FlAlBR1jdQZ0ISFR BwUMNk4nCW1DECM6 TAwDGjNnFkQBQz57 CDcvL1pUElsXOVkz Nl1pWFRQNgIWFgxC H1tACSNCTwAA X-Authentic-SMTP: 61633634383431.1023: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: > David Allsopp wrote: > >=A0Chapter 19 of the manual? Especially sections 10 "Advanced topics: mu= ltithreading" > > (http://caml.inria.fr/pub/docs/manual-ocaml/intfc.html#sec465) and 7 "A= dvanced topics: > > callbacks from C to OCaml" (http://caml.inria.fr/pub/docs/manual-ocaml/= intfc.html#sec448 > >=A0- see in particular 19.7.4) > > Thank you for your answer. > I've read the manual. That's what I'd like to know. Forgive the confusion, but 19.10 of the manual *is* the answer to your ques= tion: it describes exactly what you have to do for multiple C threads which= to make calls into the OCaml runtime. You need to use caml_c_thread_regist= er/caml_c_thread_unregister and caml_release_runtime_system/caml_acquire_ru= ntime_system. You don't need your own mutex - OCaml already has its own "ma= ster lock", as described. David