comp.lang.ada
 help / color / mirror / Atom feed
From: Christoph Grein <christoph.grein@eurocopter.de>
To: comp.lang.ada@ada.eu.org
Subject: Re: Finalization of record components which are tasks
Date: 2000/03/03
Date: 2000-03-03T18:48:18+00:00	[thread overview]
Message-ID: <200003030559.GAA12395@bulgaria.otn.eurocopter.de> (raw)

> Does the termination of a task which is a component of a controlled
> object really happen *before* the user-defined finalization subprogram
> is called?  This is really surprising.  IMHO, both common sense and
> 7.6.1(5) suggest that the task object has to be finalized *after* the
> user-defined finalization subprogram has completed.

What do you mean by "common sense"? My common sense says what happens is just
what I expect.

On Rational on Sun, the following happens:

Before Start                   <-- these two statements may
Before Task_Type.Start (R)     <-- occur in any sequence
After Task_Type.Start (R)
Before Wait
Watcher object finalized
Task has terminated
Before Wait in finalization
Exception in Finalize
TASKING_ERROR raised at 16#000E2544#, Exception Message: 

You have to take into account the notion of a master of the task in question.
Your procedure Create_Task is the master in question. It can be left only if
if all tasks it is the master of have terminated.

Now you have a terminate alternative in you task. This tells the task that it
can terminate when there is no more caller around. Your only caller is in fact
Create_Task, which is waitinf for termination so there actually is no more
caller. So the terminate alternative is chosen, the task terminates.
Finalize is called for the terminated task. Now you try to rendezvous with a
terminated task, so you get what you reqested.

If you comment out the terminate alternative, you'll get deadlock. The task
waits on a select statement no-one is around to call.

Hope that helps.









             reply	other threads:[~2000-03-03  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-03  0:00 Christoph Grein [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-03-02  0:00 Finalization of record components which are tasks Florian Weimer
2000-03-02  0:00 ` Robert A Duff
2000-03-03  0:00 ` Florian Weimer
2000-03-03  0:00   ` Robert A Duff
replies disabled

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