comp.lang.ada
 help / color / mirror / Atom feed
* Selective accept in Ada tasking
@ 2002-11-27  8:22 Ivan Paniagua
  2002-11-27  9:33 ` Peter Hermann
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Ivan Paniagua @ 2002-11-27  8:22 UTC (permalink / raw)


I'm a beginner and I have a problem. This code makes my CPU reach
100%:

task body Man_Motor1 is
begin
	while not Fin loop
		select			
			accept Subir;
			null; -- Some actions
		or
			accept Bajar;
			null; -- Some actions
		or
			accept Parar;
			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.



^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: Selective accept in Ada tasking
@ 2002-11-27 10:02 Grein, Christoph
  2002-11-27 14:17 ` Ivan
  2002-11-27 15:02 ` Adrian Knoth
  0 siblings, 2 replies; 9+ messages in thread
From: Grein, Christoph @ 2002-11-27 10:02 UTC (permalink / raw)


> I'm a beginner and I have a problem. This code makes my CPU reach
> 100%:

Looks like a bug to me. It should stop at the select and wait until there is an 
entry call. Is it possible that there is always a call present?

What happens if you remove the terminate alternative? Should not really have an 
effect, but just to see whether there is a problem in Gnat.

> 
> task body Man_Motor1 is
> begin
> 	while not Fin loop
> 		select			
> 			accept Subir;
> 			null; -- Some actions
> 		or
> 			accept Bajar;
> 			null; -- Some actions
> 		or
> 			accept Parar;
> 			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.
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada



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

end of thread, other threads:[~2002-11-29  7:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-27  8:22 Selective accept in Ada tasking Ivan Paniagua
2002-11-27  9:33 ` Peter Hermann
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

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