Periodic timer?

Robert S. Grimes rsg at
Tue Aug 21 23:57:25 UTC 2007


What is the preferred way to implement a periodic timer?  My first
attempt was to use an rtems_timer, calling rtems_timer_fire_after, but
this only fires once, and I couldn't find an option to cause it to
repeat automatically.

I ended up using rtems_rate_monotonic_period instead, even though I
don't care about missing a deadline here.  Still, it seems kind of cool
to know when I do miss a deadline!  So, here is my approach, simplified:

    // Use rate monotonic periods
    while (1) {
       status = rtems_rate_monotonic_period(period, perTicks);
       if (status != RTEMS_SUCCESSFUL) {
          reportError("Too slow!");

Question 1: Is this an appropriate (mis)use of rtems_rate_monotonic_period?

Question 2: Let's assume doWork() normally takes perhaps 50% of the
period to execute.  What happens if doWork() it takes too long every now
and then?  Is the timing of subsequent periods maintained, or is it
reestablished the next time through the loop?  I'm guessing the latter.

Question 3: Given my assertion that I don't care too much about late
deadlines here, is it an overkill compared to this approach?

    // Simple sleep
    while (1) {


More information about the users mailing list