comp.lang.ada
 help / color / mirror / Atom feed
From: Mats Weber <Mats.Weber@elca-matrix.ch>
Subject: Re: Deallocating Task objects
Date: 1997/02/17
Date: 1997-02-17T00:00:00+00:00	[thread overview]
Message-ID: <33086C65.F9F@elca-matrix.ch> (raw)
In-Reply-To: 01bc1b53$fb0251c0$829d6482@joy.ericsson.se


Jonas Nygren wrote:
> I wonder if somebody can confirm that my interpretation of this sentence
> is correct. Below I have attached a small tasking example with one
> Main_Task that dynamically allocates Sub_Tasks and I want to be absolutely
> sure that the storage used for the Sub_Tasks have been reclaimed when the
> Main_Task instance, A_Main_Task, goes out of scope.
> 
> Have I interpreted the 13.11(18) sentence correctly? Is the construct
> portable between different Ada compilers?

No, the guarantee that the space occupied by the tasks is reclaimed is
not portable. On most systems, the size (as given by 'Size) of a task
object is 32 bits (the size of a pointer), and the task object is just a
pointer to memory that describes the task. What 13.11(18) guarantees is
that the space occupied by these pointers is reclamed, but not the space
occupied by the tasks themselves (i.e. their stack, etc.).

The approach the we are using for such cases is to have a free list for
each task type that is allocated dynamically. When such a task finishes
its work, it appends itself to this free list, and it can be reused
later when a new task is needed. We then terminate the tasks in the free
lists on program termination.

It was absulutely necessary to use this approach five years ago with DEC
Ada and Verdix Ada because these implementations always kept some memory
allocated for tasks pointed to by library-level access types. I don't
know if it's still required, but we continue using that approach because
it's not much extra work as we have a generic package that we
instantiate for this purpose, and it automatically gives us some
information on how many tasks of each type we dynamically allocate.




  parent reply	other threads:[~1997-02-17  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-15  0:00 Deallocating Task objects Jonas Nygren
1997-02-15  0:00 ` Robert Dewar
1997-02-17  0:00 ` Mats Weber [this message]
1997-02-18  0:00   ` Robert L. Spooner
1997-02-18  0:00     ` Robert A Duff
1997-02-18  0:00       ` Robert Dewar
1997-02-20  0:00         ` Norman H. Cohen
1997-02-21  0:00           ` Robert Dewar
replies disabled

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