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 XAA31317 for caml-redistribution; Mon, 22 Mar 1999 23:50:53 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA00965 for ; Mon, 22 Mar 1999 21:11:50 +0100 (MET) Received: from mail13.svr.pol.co.uk (mail13.svr.pol.co.uk [195.92.193.24]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id VAA27819 for ; Mon, 22 Mar 1999 21:11:49 +0100 (MET) Received: from modem-72.adderall.dialup.pol.co.uk ([62.136.48.200] helo=toy.william.bogus) by mail13.svr.pol.co.uk with esmtp (Exim 2.12 #1) id 10PB2z-0000q8-00 for caml-list@inria.fr; Mon, 22 Mar 1999 20:11:42 +0000 Received: (from williamc@localhost) by toy.william.bogus (8.8.7/8.8.7) id UAA06832; Mon, 22 Mar 1999 20:04:33 GMT Date: Mon, 22 Mar 1999 20:04:33 GMT Message-Id: <199903222004.UAA06832@toy.william.bogus> From: William Chesters MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: caml-list@inria.fr Subject: Re: threads & OCamlTK In-Reply-To: <199903221839.NAA20107@saul.cis.upenn.edu> References: <39ADCF833E74D111A2D700805F1951EF0F00BA6B@RED-MSG-06> <199903221839.NAA20107@saul.cis.upenn.edu> X-Mailer: VM 6.34 under Emacs 20.2.1 Sender: weis Trevor Jim writes: > 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. Yes, I have found the same (Linux w/pthreads). CPU usage varies between 20% at best and near zero at worst, depending on what else is going on (that's why I originally thought Tk blocked threads completely!). > My program uses one thread to run a Tk gui. I have the gui > periodically poll for input from the other threads. I do a Fileevent.add_fileinput on a Unix pipe to which I write a byte when I want to get control of the Tk thread. Using a pipe to communicate between threads is not exactly clean but it avoids polling ... However I have now gone back to forking and passing code to execute by marshalling over IPC, because of the performance problems. Incidentally I found the most flexible thing way to support this model was to use Hashtbl in combination with Obj.magic, allowing for the creations of "sessions" with arbitrarily typed persistent state. (The interface is still type safe.)