comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adambeneschan@gmail.com>
Subject: Re: dynamic vs static tasks allocation
Date: Thu, 16 Oct 2014 11:41:51 -0700 (PDT)
Date: 2014-10-16T11:41:51-07:00	[thread overview]
Message-ID: <ed1ce8ae-fc95-42ca-bf7b-d38e78616b35@googlegroups.com> (raw)
In-Reply-To: <cb700ad1-1cb7-44e9-934d-c1580c2401c2@googlegroups.com>

On Thursday, October 16, 2014 11:18:41 AM UTC-7, mockturtle wrote:

> As a general rule, I always prefer to avoid dynamic allocation, so I prefer to allocate the task statically.  BTW, please note that if you do something like
> 
> 
> 
>    task type Foo;
> 
>    declare
>      Worker : Foo; -- Worker starts here
>    begin
>      -- Worker is running
>      ... do something ...
>    end;
> 
> task Worker is started "dynamically" when the execution reaches the "declare" block, without using "new."  I do not know if your idea of "dynamically" includes this example or not.  Also note that in this case
> 
>    procedure Bar(N: Positive) is
>      Workers : array (1..N) of Foo;  
>    begin
>       --  N workers running
>       ... do something;
>    end Bar;
> 
> the number of tasks is determined dynamically at runtime.

Also note that in the above examples, the block which declares the task (in the first example) or the procedure Bar (in the second example) will not be allowed to exit until the task(s) are done (technically, until they are "terminated").  If the block or Bar uses "new" to start the task, the block or Bar can complete while the task is still running, as long as the access type used for "new" is not declared inside the block or Bar (technically, the ultimate ancestor of the access type).  That may be another reason to use "new" to create a task.

                               -- Adam

  reply	other threads:[~2014-10-16 18:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-16 17:25 dynamic vs static tasks allocation Stribor40
2014-10-16 18:18 ` mockturtle
2014-10-16 18:41   ` Adam Beneschan [this message]
2014-10-16 18:45 ` Jeffrey Carter
2014-10-17  0:07 ` Dennis Lee Bieber
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox