From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 DE08ABBAF for ; Fri, 16 Jul 2010 06:18:38 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApsEAN55P0zV+668/2dsb2JhbACgXL52hSQEg34 X-IronPort-AV: E=Sophos;i="4.55,212,1278280800"; d="scan'208";a="66520144" Received: from rastageeks.org (HELO mail.rastageeks.org) ([213.251.174.188]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 16 Jul 2010 06:18:38 +0200 Received: from leonard.localnet (adsl-150-55-116.msy.bellsouth.net [72.150.55.116]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.rastageeks.org (Postfix) with ESMTPSA id 926D1418EF; Fri, 16 Jul 2010 06:29:08 +0200 (CEST) From: Romain Beauxis To: Goswin von Brederlow Subject: Re: [Caml-list] Smart ways to implement worker threads Date: Thu, 15 Jul 2010 23:19:10 -0500 User-Agent: KMail/1.13.3 (Linux/2.6.32-4-amd64; KDE/4.4.4; x86_64; ; ) Cc: caml-list@yquem.inria.fr References: <87sk3mcaeq.fsf@frosties.localdomain> <201007151344.12726.toots@rastageeks.org> <87lj9cw0a2.fsf@frosties.localdomain> In-Reply-To: <87lj9cw0a2.fsf@frosties.localdomain> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <201007152319.10974.toots@rastageeks.org> X-Spam: no; 0.00; buf:01 scheduler:01 scheduler:01 computed:01 buf:01 threads:01 threads:01 caml-list:01 seems:03 handler:03 let:03 let:03 checksum:04 checksum:04 timeout:05 Le jeudi 15 juillet 2010 22:52:53, Goswin von Brederlow a =E9crit : > 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. >=20 > Correct? I think it should be like this: let do_checksum buf _ =3D let sum =3D ... in reply_request (); [] let main () =3D let scheduler =3D Duppy.create () in for i =3D 1 to num_cores do Thread.create (Duppy.queue ~priorities=3D(fun x -> x =3D 1) scheduler= "worker") (); done; while (* New checksum need to be computed *) do Duppy.Task.add scheduler { priority =3D 1; events =3D [`Timeout 0.]; handler =3D fun _ -> do_= checksum buf; } done It seems in your case you do not need finer-grained priority and all the=20 workers live at the same priority level.. Now, the main thread does not need to be a task..=20 Romain