From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,10d1a90a699d6cfc X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.germany.com!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Ada tasking question Date: Wed, 18 Apr 2007 13:40:54 -0500 Organization: Jacob's private Usenet server Message-ID: References: <20070418201307.18a85fd9@cube.tz.axivion.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1176921563 12200 69.95.181.76 (18 Apr 2007 18:39:23 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 18 Apr 2007 18:39:23 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Xref: g2news1.google.com comp.lang.ada:15101 Date: 2007-04-18T13:40:54-05:00 List-Id: "Stefan Bellon" wrote in message news:20070418201307.18a85fd9@cube.tz.axivion.com... ... > Therefore I have the idea of just starting N tasks in parallel (where N > can be specified by the user e.g. according to the number of CPU cores > of the machine) instead of tasks for all buckets at once. > > Starting N tasks, then waiting for them to get all finished and only > then starting the next N tasks is not difficult. But how would I do it, > so that there are always N tasks running (apart of course when > everything has been processed) and that a new tasks is starting on the > next bucket as soon as a task on a previous bucket has finished? > > Any ideas are very welcome! I'd suggest organizing the tasks as workers and the buckets as jobs. The idea is that each task is a loop that just gets a job (a bucket in your case), processes it, sends the result, and gets another job, etc. You just need a protected data structure to serve the jobs, and an array of worker tasks, and then you can easy vary N to any value you want to try. Randy.