From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id E8D29BBAF for ; Fri, 16 Jul 2010 15:05:12 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuMBABf2P0zZSMDqkWdsb2JhbACfaRUBAQEBCQsKBxEDH746hSQE X-IronPort-AV: E=Sophos;i="4.55,214,1278280800"; d="scan'208";a="66544420" Received: from fmmailgate03.web.de ([217.72.192.234]) by mail4-smtp-sop.national.inria.fr with ESMTP; 16 Jul 2010 15:05:12 +0200 Received: from smtp07.web.de ( [172.20.5.215]) by fmmailgate03.web.de (Postfix) with ESMTP id 1A7AE15BA2FBF; Fri, 16 Jul 2010 15:05:11 +0200 (CEST) Received: from [78.43.204.177] (helo=frosties.localdomain) by smtp07.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #4) id 1OZkbG-00065n-00; Fri, 16 Jul 2010 15:05:10 +0200 Received: from mrvn by frosties.localdomain with local (Exim 4.72) (envelope-from ) id 1OZkbG-0003IF-38; Fri, 16 Jul 2010 15:05:10 +0200 From: Goswin von Brederlow To: Romain Beauxis Cc: Goswin von Brederlow , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Smart ways to implement worker threads References: <87sk3mcaeq.fsf@frosties.localdomain> <201007151344.12726.toots@rastageeks.org> <87lj9cw0a2.fsf@frosties.localdomain> <201007152319.10974.toots@rastageeks.org> Date: Fri, 16 Jul 2010 15:05:10 +0200 In-Reply-To: <201007152319.10974.toots@rastageeks.org> (Romain Beauxis's message of "Thu, 15 Jul 2010 23:19:10 -0500") Message-ID: <871vb3bmrd.fsf@frosties.localdomain> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX18xBL9LOLzls4hq3bLKdyw+C9kpGivgAYZBVUqe m3R/COE5P6nj/88bfS0I3V/dpv1HnCwWCBaMBsv7w9vbi+JdgA isyTNALYI= X-Spam: no; 0.00; buf:01 scheduler:01 scheduler:01 computed:01 buf:01 mfg:98 threads:01 threads:01 caml-list:01 writes:01 seems:03 handler:03 let:03 let:03 checksum:04 Romain Beauxis writes: > Le jeudi 15 juillet 2010 22:52:53, Goswin von Brederlow a écrit : >> The main task will only process priority 0 events and bounce between >> main_task and with_checksum while the worker threads process priority 1 >> events and do_checksum. >> >> Correct? > > I think it should be like this: > > let do_checksum buf _ = > let sum = ... > in > reply_request (); > [] > > let main () = > let scheduler = Duppy.create () > in > for i = 1 to num_cores do > Thread.create (Duppy.queue ~priorities=(fun x -> x = 1) scheduler "worker") (); > done; > while (* New checksum need to be computed *) do > Duppy.Task.add scheduler > { priority = 1; events = [`Timeout 0.]; handler = fun _ -> do_checksum buf; } > done > > It seems in your case you do not need finer-grained priority and all the > workers live at the same priority level.. > > Now, the main thread does not need to be a task.. But then how does the main thread notice when a checksum is finished computing? The information has to flow both ways. MfG Goswin