comp.lang.ada
 help / color / mirror / Atom feed
* Periodic tasks - organization
@ 2008-07-13 21:47 Maciej Sobczak
  2008-07-13 23:35 ` tmoran
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Maciej Sobczak @ 2008-07-13 21:47 UTC (permalink / raw)


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?

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-07-20  9:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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