From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA04468 for caml-redistribution; Wed, 24 Mar 1999 15:16:20 +0100 (MET) 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 QAA13540 for ; Tue, 23 Mar 1999 16:07:33 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id QAA00585; Tue, 23 Mar 1999 16:07:29 +0100 (MET) Received: (from vouillon@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA04042; Tue, 23 Mar 1999 16:07:29 +0100 (MET) Message-ID: <19990323160729.18130@pauillac.inria.fr> Date: Tue, 23 Mar 1999 16:07:29 +0100 From: Jerome Vouillon To: Trevor Jim , dsyme@microsoft.com Cc: caml-list@inria.fr Subject: Re: threads & OCamlTK References: <39ADCF833E74D111A2D700805F1951EF0F00BA6B@RED-MSG-06> <199903221839.NAA20107@saul.cis.upenn.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mutt 0.89.1 In-Reply-To: <199903221839.NAA20107@saul.cis.upenn.edu>; from Trevor Jim on Mon, Mar 22, 1999 at 01:39:10PM -0500 Sender: weis On Mon, Mar 22, 1999 at 01:39:10PM -0500, Trevor Jim wrote: > I've been using camltk with threads for a while. I find it is faster > to run Tk as its own process -- the thread scheduler doesn't seem to > do a good job with Tk involved. There is a mutex that prevents two Caml threads from running simultaneously. I think what happens is that the Tk main loop blocks while still holding the mutex. You should try to release the mutex before entering this loop, and acquire it again before each call to a Caml function. For instance, in file cltkEvents.c: +extern void enter_blocking_section (void); +extern void leave_blocking_section (void); value camltk_tk_mainloop() /* ML */ { CheckInit(); if (!signal_events) { /* Initialise signal handling */ signal_events = 1; Tk_CreateTimerHandler(100, invoke_pending_caml_signals, NULL); }; + enter_blocking_section(); Tk_MainLoop(); + leave_blocking_section(); return Val_unit; } and in file cltkCaml.c: +leave_blocking_section(); callback2(*handler_code,Val_int(id),copy_string_list(argc - 2,&argv[2])); +enter_blocking_section(); -- Jérôme