comp.lang.ada
 help / color / mirror / Atom feed
From: george.priv@gmail.com
Subject: Re: Periodic tasks - organization
Date: Sun, 13 Jul 2008 20:52:44 -0700 (PDT)
Date: 2008-07-13T20:52:44-07:00	[thread overview]
Message-ID: <80a3e3a2-d343-4de5-a529-6ce20b0318e6@x35g2000hsb.googlegroups.com> (raw)
In-Reply-To: 86589099-2e4e-4b7d-ace0-6f1f864a3fa2@y21g2000hsf.googlegroups.com

On Jul 13, 5:47 pm, Maciej Sobczak <see.my.homep...@gmail.com> 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.

If you are not concerned about those two oscillators drifting out of
phase then independent tasks will be fine.  If you do then simpler
seems to be using delay until construct.

>
> 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?
>
> --
> Maciej Sobczak *www.msobczak.com*www.inspirel.com

George



  parent reply	other threads:[~2008-07-14  3:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-13 21:47 Periodic tasks - organization Maciej Sobczak
2008-07-13 23:35 ` tmoran
2008-07-14  3:52 ` george.priv [this message]
2008-07-14  9:08 ` Alex R. Mosteo
2008-07-14 15:31   ` Anh Vo
2008-07-16 21:38     ` Simon Wright
2008-07-16 22:47       ` Anh Vo
2008-07-17 19:31         ` Simon Wright
2008-07-18 15:31           ` Anh Vo
2008-07-18 16:22             ` Dmitry A. Kazakov
2008-07-19  1:37               ` Anh Vo
2008-07-19 10:22                 ` Dmitry A. Kazakov
2008-07-20  9:46               ` Simon Wright
replies disabled

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