comp.lang.ada
 help / color / mirror / Atom feed
From: "Alex R. Mosteo" <devnull@mailinator.com>
Subject: Re: Periodic tasks - organization
Date: Mon, 14 Jul 2008 11:08:33 +0200
Date: 2008-07-14T11:08:33+02:00	[thread overview]
Message-ID: <6e0jbhF4o43oU1@mid.individual.net> (raw)
In-Reply-To: 86589099-2e4e-4b7d-ace0-6f1f864a3fa2@y21g2000hsf.googlegroups.com

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 using
extra machinery.




  parent reply	other threads:[~2008-07-14  9:08 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
2008-07-14  9:08 ` Alex R. Mosteo [this message]
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