From: Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject: Re: Multitasking
Date: Sat, 07 Dec 2002 13:33:44 -0800
Date: 2002-12-07T21:43:04+00:00 [thread overview]
Message-ID: <ofptsa.f44.ln@beastie.ix.netcom.com> (raw)
In-Reply-To: 8bRwOT7FACB@lemmies.lb.bawue.de
arvids lemchens fed this fish to the penguins on Saturday 07 December
2002 04:16 am:
> type TCPtr is access TC;
> type TList is array (Positive range <>) of TCPtr;
> CList : TList(1..10000);
>
Let's see, you create an array of pointers capable of accessing 10_000
copies of the task...
> begin
> CList(1) := new TC;
But you only create ONE task in the main body
> Put("Start Task S at: ");
> Put(Long_Long_Integer(Seconds(Clock)));
> New_Line;
> CList(1).S(60);
You then call a rendezvous entry, which means main body holds here
until the task exits the accept block -- but the accept block contains
a delay statement so both the main body and the task basically do
nothing for a while, then the task does its output and finishes the
accept block, at which point the main body continues (and the task goes
back to waiting for another entry call to be made).
> Put("End Task S ");
> Put(Long_Long_Integer(Seconds(Clock)));
> New_Line;
> Put("Start Task U ");
> Put(Long_Long_Integer(Seconds(Clock)));
> New_Line;
> CList(1).S(120);
And now you make a second rendezvous with the SAME task.
> Put("End Task U ");
> Put(Long_Long_Integer(Seconds(Clock)));
> New_Line;
> end tt;
Looks like it's doing just what you asked for (which may not be what
you meant).
The following hacked version of your code (and I see that if I do much
Ada work in Mandrake I'm going to have to figure out how to set the
default vim tab stops to 4)
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Long_Long_Integer_Text_IO; use Ada.Long_Long_Integer_Text_IO;
Procedure tt is
task type TC is
entry S(D : Positive);
end TC;
task body TC is
delayID : Positive;
begin
Put("a TC task has initiated");
New_Line;
loop
select
Accept S(D : In Positive) do
delayID := D;
end S;
or
terminate;
end select;
delay Standard.duration(delayID);
Put("Task ");
Put(Long_Long_Integer(delayID));
Put(" has finished at ");
Put(Long_Long_Integer(Seconds(Clock)));
New_Line;
end loop;
end TC;
TC_one, TC_two : TC;
begin
Put("Start Task TC_one at: ");
Put(Long_Long_Integer(Seconds(Clock)));
New_Line;
TC_one.S(120);
Put("Start Task TC_two at: ");
Put(Long_Long_Integer(Seconds(Clock)));
New_Line;
TC_two.S(60);
Put("Both tasks should be running");
New_Line;
end tt;
generates the following output:
[wulfraed@beastie wulfraed]$ ./tt
a TC task has initiated
Start Task TC_one at: 48526
Start Task TC_two at: 48526
a TC task has initiated
Both tasks should be running
Task 60 has finished at 48586
Task 120 has finished at 48646
Note: I get lucky, and the I/O overlap managed to appear at the
newlines, but with slightly different overhead, it is possible that the
"a TC task has initiated" could appear between the "... at: " and "
<clock>" output.
Also note that I made TC_one run for the longer period of time <G>
--
> ============================================================== <
> wlfraed@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
> wulfraed@dm.net | Bestiaria Support Staff <
> ============================================================== <
> Bestiaria Home Page: http://www.beastie.dm.net/ <
> Home Page: http://www.dm.net/~wulfraed/ <
next prev parent reply other threads:[~2002-12-07 21:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-07 12:16 Multitasking arvids lemchens
2002-12-07 14:09 ` Multitasking SteveD
2002-12-09 7:43 ` Multitasking arvids lemchens
2002-12-07 14:10 ` Multitasking Michal Nowak
2002-12-09 9:57 ` Multitasking arvids lemchens
2002-12-09 22:27 ` Multitasking Michal Nowak
2002-12-07 21:33 ` Dennis Lee Bieber [this message]
2002-12-08 0:17 ` Multitasking Dennis Lee Bieber
2002-12-09 9:54 ` Multitasking arvids lemchens
2002-12-09 20:48 ` Multitasking Dennis Lee Bieber
2002-12-11 12:45 ` Multitasking John English
2002-12-11 19:34 ` Multitasking Dennis Lee Bieber
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox