comp.lang.ada
 help / color / mirror / Atom feed
* Interpretation of LRM 13.10.1
@ 1990-02-23 15:48 "Fred Zwarts, KVI, Groningen, NL."
  1990-02-27 15:50 ` Jerry Callen
  1990-02-27 19:47 ` Loren Louis Hart
  0 siblings, 2 replies; 7+ messages in thread
From: "Fred Zwarts, KVI, Groningen, NL." @ 1990-02-23 15:48 UTC (permalink / raw)


Hello all,

I am rather new to Ada and I am not quite sure that this is the right place to
ask, but I do not know a better place.

I am uncertain about the interpretation of LRM 13.10.1(8) on the
UNCHECKED_DEALLOCATION procedure, where I read:

"If X designates a task object, the call FREE(X) has no effect on the task
...".

My question is: What means "no effect"?
Suppose X designates a terminated task, see LRM 9.4(6-10).
Can FREE(X) be used to reclaim memory held by such a terminated task, like a
task control block? Does the LRM allow such an interpretation?

If this interpretation is not allowed, I can imagin a case in which one runs
out of memory because of a large amount of terminated tasks. If always at least
one such task is running, it is not possible to leave the block in which the
declaration of X's type was elaborated LRM 9.4(6), which could otherwise be a
way to reclaim memory.

Fred Zwarts                             E-mail:         INFOADA@KVI.nl
Kernfysisch Versneller Instituut
9747 AA  Groningen
The Netherlands

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Interpretation of LRM 13.10.1
@ 1990-02-27 14:15 Mats Weber
  0 siblings, 0 replies; 7+ messages in thread
From: Mats Weber @ 1990-02-27 14:15 UTC (permalink / raw)


>I am rather new to Ada and I am not quite sure that this is the right place to
>ask, but I do not know a better place.

It is the right place to ask.

>I am uncertain about the interpretation of LRM 13.10.1(8) on the
>UNCHECKED_DEALLOCATION procedure, where I read:

>"If X designates a task object, the call FREE(X) has no effect on the task
>...".

>My question is: What means "no effect"?
>Suppose X designates a terminated task, see LRM 9.4(6-10).
>Can FREE(X) be used to reclaim memory held by such a terminated task, like a
>task control block? Does the LRM allow such an interpretation?

The LRM says nothing about the deallocation of the working storage (stack space,

etc.) of tasks. Most implementations I know of reclaim that storage when the
block that declares the corresponding task type is left, but this behaviour is
not required by the LRM.
"no effect" means that calling Free(X) does not affect the execution of the
designated task, in particular, the designated task does not stop and must still

terminate before its master can be exited. Free(X) simply makes the designated
task inaccessible.

>If this interpretation is not allowed, I can imagin a case in which one runs
>out of memory because of a large amount of terminated tasks. If always at least

>one such task is running, it is not possible to leave the block in which the
>declaration of X's type was elaborated LRM 9.4(6), which could otherwise be a
>way to reclaim memory.

You are right. Most implementations do not reclaim the stack storage of
terminated tasks. A workaround is to put these unused tasks into a pool and
reuse them, allocating new tasks only when the pool is empty.

Mats Weber
Swiss Federal Institute of Technology
EPFL DI LGL
1015 Lausanne
Switzerland

E-mail : madmats@elcit.epfl.ch
phone  : +41 21 693 52 92
fax    : +41 21 693 22 20

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Interpretation of LRM 13.10.1
@ 1990-02-27 14:51 "Norman H. Cohen"
  0 siblings, 0 replies; 7+ messages in thread
From: "Norman H. Cohen" @ 1990-02-27 14:51 UTC (permalink / raw)


13.10.1(8) is one of the most often misinterpreted paragraphs in the RM.
(Fortunately, it's a note, and therefore not officially part of the
language definition.  LRM 2.7(1) states, "Furthermore, comments do not
influence the effect of a program; their sole purpose is the
enlightenment of the human reader."  John Goodenough once quipped that
the LRM Note paragraphs do not influence the definition of the language;
their sole purpose is to confuse the reader.)

There are two sources of confusion:

1. Informally, we often use the word "task" to mean a task unit or a
   task object.  However, in the (usually) precise language of the LRM,
   a "task" in Ada is neither an object nor a program unit, but a process
   (a thread of control).  A TASK OBJECT "designates" some task.
   (See 9(2) and 9.2(2).)

2. The word "designates" also has another technical meaning in the LRM:
   An access value "designates" the object it points to (see 3.8(1)).
   Unfortunately, the word "designates" is used in both senses in the
   first sentence of 13.10.1(8).

Now lets look at the first sentence of 13.10.1(8):

   If X designates a task object, the call FREE(X) has no effect on
   the task designated by the task object.

(Here X is an access value and FREE is an instance of
UNCHECKED_DEALLOCATION.)  An informal paraphrase is:

   If X points to a task object, the call FREE(X) has no effect on
   the thread of control corresponding to that task object.

Thus, for example, you can't abort a task by attempting to deallocate it.

When an instance of UNCHECKED_DEALLOCATION is applied to a task object
designating a terminated task, a good compiler will reclaim the storage
occupied by the task object.  Not all compilers are good.

Norman H. Cohen

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1990-03-05 17:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1990-02-23 15:48 Interpretation of LRM 13.10.1 "Fred Zwarts, KVI, Groningen, NL."
1990-02-27 15:50 ` Jerry Callen
1990-03-02 18:21   ` stt
1990-03-05 17:01     ` John Goodenough
1990-02-27 19:47 ` Loren Louis Hart
  -- strict thread matches above, loose matches on Subject: below --
1990-02-27 14:15 Mats Weber
1990-02-27 14:51 "Norman H. Cohen"

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