From: Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject: Re: Multitasking
Date: Sat, 07 Dec 2002 16:17:22 -0800
Date: 2002-12-08T00:26:55+00:00 [thread overview]
Message-ID: <i23usa.tf4.ln@beastie.ix.netcom.com> (raw)
In-Reply-To: ofptsa.f44.ln@beastie.ix.netcom.com
Dennis Lee Bieber fed this fish to the penguins on Saturday 07 December
2002 01:33 pm:
> [wulfraed@beastie wulfraed]$ ./tt
> a TC task has initiated
> Start Task TC_one at: 48526
> Start Task TC_two at: 48526
Hmmm, using whole seconds (and why Long_Long yet?) hides some of the
timing granularity. Let's try again with a bit more detail, and a
second invocation of the entry calls so you can see the effect of a
rendezvous blocking action.
Try this one, which overlaps a few invocations to each task. (My
apologies for the clumsy myPutFloat definition -- no doubt there is a
more efficient way of doing the same without coding the fore/aft/exp
arguments on all calls -- while I've always liked the language [did a
presentation on Ada in my senior year, before the it had even been
finalized as a DOD standard] I've never really /used/ the language).
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
Procedure tt is
procedure myPutFloat(F : Float) is
begin
Put(F, Fore=>6, Aft=>5, Exp=>0);
end;
task type TC is
entry S(D : Positive);
end TC;
task body TC is
delayID : Positive;
begin
Put("a TC task has initiated at: ");
myPutFloat(Float(Seconds(Clock)));
New_Line;
loop
select
Accept S(D : In Positive) do
myPutFloat(Float(D));
Put(" Accepted at: ");
myPutFloat(Float(Seconds(Clock)));
New_Line;
delayID := D;
end S;
or
terminate;
end select;
delay Standard.duration(delayID);
Put("Task ");
myPutFloat(Float(delayID));
Put(" has finished at ");
myPutFloat(Float(Seconds(Clock)));
New_Line;
end loop;
end TC;
TC_one, TC_two : TC;
begin
Put("Rendezvous Task TC_one at: ");
myPutFloat(Float(Seconds(Clock)));
New_Line;
TC_one.S(120);
Put("Rendezvous Task TC_two at: ");
myPutFloat(Float(Seconds(Clock)));
New_Line;
TC_two.S(60);
Put("Both tasks should be running");
New_Line;
Put("Rendezvous Task TC_two at: ");
myPutFloat(Float(Seconds(Clock)));
New_Line;
TC_two.S(10);
Put("Rendezvous Task TC_one at: ");
myPutFloat(Float(Seconds(Clock)));
New_Line;
TC_one.S(20);
Put("Rendezvous Task TC_two at: ");
myPutFloat(Float(Seconds(Clock)));
New_Line;
TC_two.S(15);
Put("Waiting for last task to finish");
New_Line;
end tt;
The results on my machine are:
[wulfraed@beastie ada]$ ./tt
a TC task has initiated at: 58287.18750
Rendezvous Task TC_one at: 58287.18750
120.00000 Accepted at: 58287.18750
Rendezvous Task TC_two at: 58287.19141
a TC task has initiated at: 58287.19141
60.00000 Accepted at: 58287.19141
Both tasks should be running
Rendezvous Task TC_two at: 58287.19141
Task 60.00000 has finished at 58347.19141
10.00000 Accepted at: 58347.19141
Rendezvous Task TC_one at: 58347.19141
Task 10.00000 has finished at 58357.20313
Task 120.00000 has finished at 58407.19141
20.00000 Accepted at: 58407.19141
Rendezvous Task TC_two at: 58407.19141
15.00000 Accepted at: 58407.19141
Waiting for last task to finish
Task 15.00000 has finished at 58422.20313
Task 20.00000 has finished at 58427.20703
--
> ============================================================== <
> 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-08 0:17 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 ` Multitasking Dennis Lee Bieber
2002-12-08 0:17 ` Dennis Lee Bieber [this message]
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