From: Jano <nono@celes.unizar.es>
Subject: Tasks unleashed
Date: Thu, 1 May 2003 16:01:48 +0200
Date: 2003-05-01T16:01:48+02:00 [thread overview]
Message-ID: <MPG.191b473be18428019896f1@News.CIS.DFN.DE> (raw)
Hello again,
now my question is referred to the use of task types through access
types.
I seem to remember from a distant conversation that every task allocated
takes a small amount of memory, amongst other things, to provide
satisfactory results for 'Callable attribute.
Sometimes I'd like to have a task type that, when some activity is
needed, is created and forgotten. For example, it takes an access
constraint and from that point on is completely independent.
A related aspect is that I don't know if Unchecked_deallocation is to be
performed on tasks. See the following example:
------8<---------
with Ada.Unchecked_deallocation;
procedure test is
task type tt is
entry The_end;
end tt;
task body tt is
begin
accept The_end do
null;
end The_end;
-- delay 1.0;
end tt;
type att is access all tt;
x : att;
procedure Free is new Ada.Unchecked_deallocation (tt, att);
begin
loop -- for N in 1 .. 100 loop
x := new tt;
x.The_end;
Free (x);
end loop;
end;
------8<---------
It illustrates various points that come to my mind:
*) It eats quickly all my memory (Gnat 3.15p)
*) You can't be sure that the task is terminated when free is tried (and
no exception is raised in that case).
*) Free seems to do nothing (gnatmem reports 0 deallocations using a
closed loop of 100 iterations).
In any case, the memory thing forces to use pools of reusable tasks,
it's my main and crucial conclusion.
Even if Free for tasks were not to free resources, it seems reasonable
that it could instruct the runtime that that task will not be referenced
again, so it should leave a 0 memory footprint after termination? But
now I'm making things up, I can't find right now specific comments in
the ARM about task access types.
Could someone comment on these things? Behave differently other
compilers? I'm a fool to try these things or simply an ignorant?
I should say that I have an innate instinct to try to resolve things the
way others see distinctly are not to be tried :)
Now that there is an ongoing discussion about people not knowing Ada
using it for large new developments, think about it: I have some fair
experience, several years of exposure (but only one fairly sized project
behind me), and I'm still trying these twisted things. What could do a
complete ignorant :) My other glorious idea yesterday was to free a
protected type from inside one of its own procedures. I did it, but
decided not to carry on (nothing seemed immediately wrong, though)...
What things could arise from that?
--
-------------------------
Jano
402450.at.cepsz.unizar.es
-------------------------
next reply other threads:[~2003-05-01 14:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-01 14:01 Jano [this message]
2003-05-01 15:40 ` Tasks unleashed Stephen Leake
2003-05-01 16:14 ` Robert A Duff
2003-05-01 16:30 ` Jano
2003-05-02 1:14 ` tmoran
2003-05-02 11:21 ` Jano
2003-05-02 23:52 ` tmoran
2003-05-11 5:35 ` Craig Carey
2003-05-11 15:35 ` Pascal Obry
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox