From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.8 required=5.0 tests=DNS_FROM_RFC_POST,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id BD717BBAF for ; Sat, 11 Jul 2009 09:54:07 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoEBALzhV0pIDtybimdsb2JhbACYZj8BAQEKCQwHEQWiTYEakEgBAwIEBYIwgVAF X-IronPort-AV: E=Sophos;i="4.42,383,1243807200"; d="scan'208";a="32872961" Received: from fg-out-1718.google.com ([72.14.220.155]) by mail1-smtp-roc.national.inria.fr with ESMTP; 11 Jul 2009 09:54:07 +0200 Received: by fg-out-1718.google.com with SMTP id l26so363365fgb.20 for ; Sat, 11 Jul 2009 00:54:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type; bh=i6KjtHwOu4x793k+Fv8jfQPxKbt4rChZbqPZOwNMygc=; b=X2bV0gS39J1Li1BnNmaqDPonZVfKPYsXc2VBufAvl1hwhMY3b4LB+Nw9MluVgsb0u4 5pT1vgC3FdKuZhxVJUtFlCKzkxCN4nvz1L5VzPj0nnQQbjgkFbSthiZuXRTd8BXrbruH GykOf3DmJqOcGgrZjhSNuAICKS/tx0Gf/KCvg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; b=o77sf17N69UOs53JtL8tA8Occ6KLNW7e3D/90xhhI+e9GbsoxJFhL/YBCSLSUsZF+R 6aUZvxYomCFM1IWb5a9lOUYLWC3ghf9JUJlFjnvM9ZWUdU2BRqVafKybyBQ+d9YbiQD2 L/njbMHDp8NmM2gTv9CmmsZLvQvtg77Wbg+8U= Received: by 10.86.27.13 with SMTP id a13mr1638931fga.49.1247298847084; Sat, 11 Jul 2009 00:54:07 -0700 (PDT) Received: from lemon (143-111-132-95.pool.ukrtel.net [95.132.111.143]) by mx.google.com with ESMTPS id d4sm424159fga.24.2009.07.11.00.54.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 11 Jul 2009 00:54:06 -0700 (PDT) Date: Sat, 11 Jul 2009 10:54:03 +0300 From: ygrek To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Callbacks from C to OCaml Message-Id: <20090711105403.8bb1e112.ygrekheretix@gmail.com> In-Reply-To: <000d01ca014f$e119a980$a34cfc80$@com> References: <000d01ca014f$e119a980$a34cfc80$@com> X-Mailer: Sylpheed 2.5.0 (GTK+ 2.12.12; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="PGP-SHA1"; boundary="Signature=_Sat__11_Jul_2009_10_54_03_+0300_pLv2.a_+Oe0E5rRD" X-Spam: no; 0.00; callbacks:01 ocaml:01 ocaml:01 ocaml's:01 threading:01 runtime:01 2009:98 scm:98 scm:98 invoke:01 wrote:01 executes:01 caml-list:01 closure:01 boolean:01 X-Attachments: type="application/pgp-signature" --Signature=_Sat__11_Jul_2009_10_54_03_+0300_pLv2.a_+Oe0E5rRD Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, 10 Jul 2009 12:16:17 +0100 "David Allsopp" wrote: > Now, at any time, the SCM may invoke the ServiceCtrlHandler function > registered with it. This also needs to callback to an OCaml function to w= ork > out what to do (the closure was registered in the initial call). >=20 > What happens at this point with regard to OCaml's global lock and being in > the correct threading context? I must confess that I don't fully understa= nd > how the callback works at all in the single-threaded context - presumably > when SCM calls the function, it simply executes code in its own thread > context (so it can presumably introduce a form of multi-threading to a > program which isn't expecting it?). Yes, SCM creates new thread for the callback. And this thread is not registered with OCaml runtime, and so you can't do any allocation on it. I used windows services in the same setu= p and =20 just set a boolean flag when SCM signalled service to stop, while periodica= lly checking this flag in ocaml thread.. See also http://caml.inria.fr/mantis/view.php?id=3D4702 Hope it helps. --=20 ygrek --Signature=_Sat__11_Jul_2009_10_54_03_+0300_pLv2.a_+Oe0E5rRD Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkpYRRsACgkQY0a5RXCNWgzGJQCgqGvYtJeB3cuvZNIc43uCAwc3 PI0An3P7dhZ4H1odWmfWKdkVvmf+hMjU =RLfS -----END PGP SIGNATURE----- --Signature=_Sat__11_Jul_2009_10_54_03_+0300_pLv2.a_+Oe0E5rRD--