From: "Alex R. Mosteo" <devnull@mailinator.com>
Subject: Re: Ada tasking question
Date: Wed, 18 Apr 2007 22:50:21 +0300
Date: 2007-04-18T22:50:21+03:00 [thread overview]
Message-ID: <58nb3uF2gtp0vU1@mid.individual.net> (raw)
In-Reply-To: 20070418201307.18a85fd9@cube.tz.axivion.com
Stefan Bellon wrote:
> Hi all!
>
> Although I am quite familiar with Ada, tasking is quite new to me, so
> please bear with me with my question. ;-)
>
> I have a set of buckets where I do have to do some processing on them.
> This processing can be done in parallel for each bucket. The results
> of the processing however are accumulated into another data structure.
>
> At present I have task types for the processing of the buckets, an
> access type to the task type and basically just do:
>
> declare
> type Task_Access is access all Task_Type;
> My_Task : Task_Access;
> begin
> for I in Buckets'Range loop
> My_Task := new Task_Type'(Buckets (I));
Be aware that this causes heap consumption. That is, a finished task doesn't
just vanishes, it has some heap used for task context that is not
automatically released. To properly free a task access you must ensure that
the task is terminated (My_Task'Terminated) before doing an
Unchecked_Deallocation.
If you try to free an unfinished task, the call won't fail but the task
context memory won't be freed...
I have only GNAT experience though.
> end loop;
> end;
>
> The result data structure is a protected object with an entry Add that
> adds the processing result to the container and which is called by the
> task body.
>
> All is well so far.
>
> However the number of buckets may be quite large and I have the feeling
> that the context switching which is needed for say 1000 or more tasks
> eats up the gain of the parallelism. At least in my test cases I do not
> gain anything at all on a Core Duo system.
>
> 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!
>
next prev parent reply other threads:[~2007-04-18 19:50 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-18 18:13 Ada tasking question Stefan Bellon
2007-04-18 18:40 ` Randy Brukardt
2007-04-18 20:12 ` Jeffrey R. Carter
2007-04-18 22:43 ` Stefan Bellon
2007-04-19 2:02 ` Steve
2007-04-18 21:08 ` Leif Holmgren
2007-04-18 22:57 ` Stefan Bellon
2007-04-18 23:41 ` Brian May
2007-04-19 0:25 ` Randy Brukardt
2007-04-19 8:02 ` Stefan Bellon
2007-04-19 12:47 ` Jacob Sparre Andersen
2007-04-19 16:11 ` Anh Vo
2007-04-20 4:32 ` Jeffrey R. Carter
2007-04-19 0:50 ` Jeffrey R. Carter
2007-04-18 19:50 ` Alex R. Mosteo [this message]
2007-04-18 23:00 ` Stefan Bellon
2007-04-19 20:37 ` Pascal Obry
2007-04-19 2:13 ` jimmaureenrogers
2007-04-19 7:49 ` Dmitry A. Kazakov
-- strict thread matches above, loose matches on Subject: below --
1996-10-18 0:00 whiting_ms@corning.com (Matt Whiting)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox