From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a023f5759065182 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-27 01:33:20 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!newsfeed.media.kyoto-u.ac.jp!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!news.tu-darmstadt.de!news.belwue.de!news.uni-stuttgart.de!not-for-mail From: Peter Hermann Newsgroups: comp.lang.ada Subject: Re: Selective accept in Ada tasking Date: Wed, 27 Nov 2002 09:33:19 +0000 (UTC) Organization: Comp.Center (RUS), U of Stuttgart, FRG Message-ID: References: NNTP-Posting-Host: iris16.csv.ica.uni-stuttgart.de X-Trace: news.uni-stuttgart.de 1038389599 27841 129.69.118.32 (27 Nov 2002 09:33:19 GMT) X-Complaints-To: news@news.uni-stuttgart.de NNTP-Posting-Date: Wed, 27 Nov 2002 09:33:19 +0000 (UTC) User-Agent: tin/pre-1.4-980117 (UNIX) (IRIX/6.5 (IP22)) Xref: archiver1.google.com comp.lang.ada:31246 Date: 2002-11-27T09:33:19+00:00 List-Id: Ivan Paniagua 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)