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 KAA14122; Wed, 14 Apr 2004 10:10:00 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 KAA13983 for ; Wed, 14 Apr 2004 10:09:59 +0200 (MET DST) Received: from mail0.epfl.ch (mail0.epfl.ch [128.178.50.57]) by concorde.inria.fr (8.12.10/8.12.10) with SMTP id i3E89wYM013871 for ; Wed, 14 Apr 2004 10:09:58 +0200 Received: (qmail 15295 invoked by uid 107); 14 Apr 2004 08:09:58 -0000 Received: from mailav1.epfl.ch (HELO MAILAV1) (128.178.50.190) by mail0.epfl.ch with SMTP; 14 Apr 2004 08:09:58 -0000 Received: From mail0.epfl.ch ([128.178.50.57]) by MAILAV1 (WebShield SMTP v4.5 MR1a P0803.345); id 1081930406715; Wed, 14 Apr 2004 10:13:26 +0200 Received: from lamp2priv1.epfl.ch (128.178.154.46) by mail0.epfl.ch (AngelmatoPhylax SMTP proxy); Wed, 14 Apr 2004 10:09:58 +0200 In-Reply-To: <407CD31D.5080001@univ-savoie.fr> References: <407B9D6F.70800@univ-savoie.fr> <20040413194854.GB27613@davidb.org> <407CD31D.5080001@univ-savoie.fr> Mime-Version: 1.0 (Apple Message framework v613) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Message-Id: <44F959F8-8DEB-11D8-A972-000393DBC266@epfl.ch> Content-Transfer-Encoding: quoted-printable Cc: caml-list@inria.fr From: =?ISO-8859-1?Q?Daniel_B=FCnzli?= Subject: Re: [Caml-list] Scheduling thread problem kernel 2.6 Date: Wed, 14 Apr 2004 10:11:02 +0200 To: Christophe Raffalli X-Mailer: Apple Mail (2.613) X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 raffalli:01 stub:01 camlprim:01 val:01 threads:01 callback:01 callbacks:01 callback:01 myfun:01 val:01 ecrit:01 kernel:01 christophe:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 313 Le 14 avr. 04, =E0 07:58, Christophe Raffalli a =E9crit : > I do not understand ? First I launch the interface thread from Caml=20 > with > Thread.create and the interface thread calls Glut.main_loop which=20 > never ends (except when the program terminates). This main loop call=20= > some Caml functions. My understanding is that the Glut.main_loop stub should be something=20 like #include CAMLprim value ocaml_glutMainLoop(value v) { enter_blocking_section(); glutMainLoop(); leave_blocking_section(); /* This will in fact never be called = */ return Val_unit; } enter_blocking_section() releases the master mutex that ensures single=20= threaded execution of caml code and allows other caml threads to=20 proceed. Now each callback calling back from C into caml should=20 reacquire the master lock to avoid concurrent execution of caml code.=20 To do so callbacks from C into caml should be wrapped as follows, ... leave_blocking_section(); callback(*caml_named_value("myfun"), Val_unit); enter_blocking_section(); ... See also this message Hope that helps, Daniel= ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners