From: Peter Hermann <ica2ph@iris16.csv.ica.uni-stuttgart.de>
Subject: Re: Selective accept in Ada tasking
Date: Wed, 27 Nov 2002 09:33:19 +0000 (UTC)
Date: 2002-11-27T09:33:19+00:00 [thread overview]
Message-ID: <as23gv$r61$1@news.uni-stuttgart.de> (raw)
In-Reply-To: c560b18f.0211270022.72569d49@posting.google.com
Ivan Paniagua <paniaguaivan@hotmail.com> wrote:
> I'm using GNAT 3.14 in a Windows XP platform. If I introduce a delay
> before de end loop all it's OK, but what I want is that the task keep
> sleeping till it has a call to an entry without consuming a lot of CPU
> time.
I am using GNAT3.15p windows2000 CPU600MHz.
The delay within the loop of the accepting task seems not be justified
IMHO because this task should be constantly alert and working on demand.
The consumer task on the other side defines the needs and if necessary,
the CPU then goes up to 100%, of course. If not, then not :-)
The following code shows a pretty CPU usage profile in windows task manager:
procedure paniaguaivan is
value : float := 0.0;
fin : boolean := false;
--From: paniaguaivan@hotmail.com (Ivan Paniagua)
--Newsgroups: comp.lang.ada
--Subject: Selective accept in Ada tasking
--Date: 27 Nov 2002 00:22:41 -0800 Wed Nov 27 09:33:53 2002
--Organization: http://groups.google.com/
--Lines: 28
--I'm a beginner and I have a problem. This code makes my CPU reach 100%:
procedure work is begin
for i in 1..1e7 loop
value := float(i+i)+0.5;
end loop;
end work;
task Man_Motor1 is
entry subir;
entry bajar;
entry parar;
end Man_Motor1;
task body Man_Motor1 is
begin
while not Fin loop
select
accept Subir; --aufstehen, go up, monter
work;--null; -- Some actions
or
accept Bajar; -- come down
null; -- Some actions
or
accept Parar; -- anhalten, die, stoj
null; -- Some actions
or
terminate;
end select;
end loop;
end Man_Motor1;
--I'm using GNAT 3.14 in a Windows XP platform. If I introduce a delay
--before de end loop all it's OK, but what I want is that the task keep
--sleeping till it has a call to an entry without consuming a lot of CPU
--time.
--Can anybody help me?
--Thank you very much.
begin
loop
Man_Motor1.subir;
Man_Motor1.bajar;
Man_Motor1.parar;
delay 3.0;
end loop;
end paniaguaivan;
--
--Peter Hermann(49)0711-685-3611 fax3758 ica2ph@csv.ica.uni-stuttgart.de
--Pfaffenwaldring 27 Raum 114, D-70569 Stuttgart Uni Computeranwendungen
--http://www.csv.ica.uni-stuttgart.de/homes/ph/
--Team Ada: "C'mon people let the world begin" (Paul McCartney)
next prev parent reply other threads:[~2002-11-27 9:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-27 8:22 Selective accept in Ada tasking Ivan Paniagua
2002-11-27 9:33 ` Peter Hermann [this message]
2002-11-27 14:41 ` SteveD
2002-11-27 16:14 ` tmoran
2002-11-29 7:02 ` Ivan
-- strict thread matches above, loose matches on Subject: below --
2002-11-27 10:02 Grein, Christoph
2002-11-27 14:17 ` Ivan
2002-11-27 14:56 ` Preben Randhol
2002-11-27 15:02 ` Adrian Knoth
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox