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=0.7 required=5.0 tests=BAYES_00,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f8311a3a7edd715 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-12 14:40:11 PST Path: supernews.google.com!sn-xit-02!supernews.com!newsfeed.mesh.ad.jp!hermes.visi.com!news-out.visi.com!news.idt.net!feed2.news.rcn.net!rcn!dc1.nntp.concentric.net!newsfeed.concentric.net!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: Ted Dennison Newsgroups: comp.lang.ada Subject: Re: Using "delay until" in real-time Date: Tue, 12 Dec 2000 22:31:14 GMT Organization: Deja.com Message-ID: <9168vi$7mp$1@nnrp1.deja.com> References: <915jl7$jt5$1@nnrp1.deja.com> NNTP-Posting-Host: 204.48.27.130 X-Article-Creation-Date: Tue Dec 12 22:31:14 2000 GMT X-Http-User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; m18) Gecko/20001207 X-Http-Proxy: 1.0 x51.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 X-MyDeja-Info: XMYDJUIDtedennison Xref: supernews.google.com comp.lang.ada:3019 Date: 2000-12-12T22:31:14+00:00 List-Id: In article , JP Thornley wrote: > In article <915jl7$jt5$1@nnrp1.deja.com>, Ted Dennison > writes > >1/60 works out to about 0.016(6-repeating). That can't be accurately > >represented in an IEEE floating-point register. So what we get is > >something like 0.016667 (forgive me if I'm rounding the wrong digit). > > Why not use 3 'minor' cycles in a 'major' cycle. > > The major cycle then has an exact delay of 0.05, and the minor cycles > are offset by 0.016667 and 0.033333 within the major cycle. Ahhh, someone who speaks our language. :-) It looks like you are essentially suggesting that the scheduler do something like: Minor_Iteration_Rate : constant := 1.0/60.0; Major_Iteration_Rate : consant := 0.05; begin loop -- do work for Minor_Cycle in 1..2 loop delay until Next_Time + Iteration_Rate * Minor_Cycle; -- do work end loop; Next_Time := Next_Time + Major_Iteration_Rate; delay until Next_Time; end loop; I think this is essentially the same as my iteration-counting scheme, except that the "Major_Iteration_Rate" is set to 0.05 instead of 1.0, and the number of minor cycles is hard-coded. I did simplify things a bit for my question. We are actually using 4 minor cycles in our 60Hz major cycle. Under the scheme we use here things can only run once a major cycle, so the fastest with the current settings would be 60Hz. However, we can adjust the minor cycle used in order to prevent jitter in those tasks that are expecially sensitive to it (eg: Controls and the Visual system). So our executive is *actually* running at 240Hz (but of course this doesn't affect the math problem. 1/240th still a repeating decimal). -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/