comp.lang.ada
 help / color / mirror / Atom feed
From: "Norman H. Cohen" <ncohen@watson.ibm.com>
Subject: Re: Task Access Type Variables
Date: Fri, 19 Jul 91 09:22:16 EDT	[thread overview]
Message-ID: <9107191345.AA26383@ajpo.sei.cmu.edu> (raw)

 >         What happens to the value of a variable which
 > is an access to a task (type) once the task completes
 > its job or terminates for some reason?
 >
 >         Does this access type variable become NULL or
 > will it access some garbage location?

It continues to be a valid pointer to a task object.  The task object
just happens to designate a terminated task.  (This is no different from
what happens to a DECLARED task object when the task terminates.  The
task object continues to exist.)

 >         I could just use the TVAR.all'CALLABLE or
 > TVAR.all'TERMINATED task attributes to see what the
 > status of the task that TVAR points to is. (Of
 > course, I'll check to make sure that TVAR /= null
 > before I do this).

Indeed.  Calling an entry of a terminated task will raise TASKING_ERROR,
but one thing you CAN do with a task object designating a terminated
task is to evaluate its 'CALLABLE and 'TERMINATED attributes.  This is
why a task OBJECT must stay around even after the TASK it designates
has terminated.

(Remember:  A "task" is a process.  A "task object" is a variable
that "designates" that process and holds certain information about it,
including whether the process has terminated.)

There is no need to check that TVAR /= null.  Termination of a task
does not trigger a search for all variables holding pointers to the
corresponding task object so that those variables can be set to null!

 > Also...can garbage collection be done on task access
 > type variables? This seems like it shouldn't be possible.

I think you're asking whether dynamically allocated task objects
(rather than pointers to task objects) can be garbage collected.
The answer is yes, provided that two conditions hold:

   1. The object is no longer reachable by a chain of active pointers
      (i.e., it is "garbage" in the usual sense).

   2. The designated task has terminated.

(See paragraph 4.8(7) in the reference manual.)

Of course no Ada compiler yet provides garbage collection for ANY types,
let alone task types.

             reply	other threads:[~1991-07-19 13:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-07-19 13:22 Norman H. Cohen [this message]
  -- strict thread matches above, loose matches on Subject: below --
1991-07-20  0:38 Task Access Type Variables Robert I. Eachus
1991-07-19 14:30 Jean Pierre Rosen
1991-07-18 21:03 J o s e D u a r t e
1991-07-18 19:12 J o s e D u a r t e
replies disabled

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