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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,470e89e7a6575920 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!r66g2000hsg.googlegroups.com!not-for-mail From: Anh Vo Newsgroups: comp.lang.ada Subject: Re: Periodic tasks - organization Date: Mon, 14 Jul 2008 08:31:07 -0700 (PDT) Organization: http://groups.google.com Message-ID: <561c8fa7-f26d-49a3-b54c-229c20462c04@r66g2000hsg.googlegroups.com> References: <86589099-2e4e-4b7d-ace0-6f1f864a3fa2@y21g2000hsf.googlegroups.com> <6e0jbhF4o43oU1@mid.individual.net> NNTP-Posting-Host: 209.225.224.254 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1216049468 29312 127.0.0.1 (14 Jul 2008 15:31:08 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 14 Jul 2008 15:31:08 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r66g2000hsg.googlegroups.com; posting-host=209.225.224.254; posting-account=Qh2kiQoAAADpCLlhT_KTYoGO8dU3n4I6 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; InfoPath.1; .NET CLR 3.0.04506.648),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:1150 Date: 2008-07-14T08:31:07-07:00 List-Id: On Jul 14, 2:08=A0am, "Alex R. Mosteo" wrote: > Maciej Sobczak wrote: > > Consider a program that has a couple of periodic tasks. Let's say > > there are two tasks, one with a period of 3s and another with a period > > of 4s. Let's say that exact triggering is not required. > > > The simplest way to do it is to just have appropriate delay statements > > in main loops of these tasks. The advantage of such a setup is that > > the tasks are completely self-contained and independent on any other > > program entity. The disadvantage is that they are bound to the way > > their periodicity is implemented. > > > Another way is to have additional task that will serve as a clock, > > "ticking" two protected objects that are countdown counters with > > single entry that waits for the counter to reach zero. In this case > > the tick would be 1s, as the greatest common divisor of two periods. > > The working tasks can then wait on respective entries in these > > protected objects, which are released when the counters reach zero. > > The advantage of this approach is that the notion of time is extracted > > from the working tasks themselves and can be easily changed to > > something else, like waiting on a different kind of clock or an > > interrupts or whatever without disturbing main working tasks. The > > disadvantage is that there are more program entities (+ two protected > > countdowns + 1 ticking task) to handle. > > > What can you say about these two approaches? Which would you recommend > > and when? > > I would use "delay until", which prevents any drift and still avoids usin= g > extra machinery.- Hide quoted text - > > - Show quoted text - It is even better to use periodic timers built on top Ada.Real_Time.Timing_Events. Then, explicit tasks are not needed. Anh Vo