rate_monotonic with different periods
Aaron J. Grier
aaron at frye.com
Wed Aug 21 00:58:34 UTC 2002
with rtems-4.5.0 on m68k with custom BSP.
I have (according to the parlance used in the documentation) a sporadic
task which has hard deadlines, but is not periodic. from what I've
read, the rate monotonic manager looks like it should give me exactly
what I'm after:
rtems_rate_monotonic_period(period_id, 1);
/*
* do some work here that needs to run in 1 tick
*/
/* block until the 1 tick time is up or return TIMEOUT, and reset our
* period to 200 ticks */
rtems_rate_monotonic_period(period_id, 200);
/*
* do some work that needs to run in 200 ticks
*/
/* block until the 200 ticks are up or return TIMEOUT, and reset the
* period to 3 ticks */
rtems_rate_monotonic_period(period_id, 3);
reading the code for rtems_rate_monotonic_period, it looks like the
period timer does not get reset unless the_period->state is either
INACTIVE or EXPIRED, and this is consistent with the behavior I'm
seeing, IE all subsequent calls to rtems_rate_monotonic_period() behave
as if they were called with the same length, in this case 1.
the documentation gives the example: (abridged for illustration)
while (1) {
if (rate_monotonic_period( period_1, 100 ) == TIMEOUT) break;
if (rate_monotonic_period( period_2, 40 ) == TIMEOUT) break;
/* do work from 0-39 ticks */
if (rate_monotonic_period( period_2, 30 ) == TIMEOUT) break;;
/* do work from 40-69 ticks */
if (rate_monotonic_period( period_2, STATUS ) == TIMEOUT) break;
rate_monotonic_cancel( period_2 );
}
if my reading of the code is correct, the second work period actually
has from 40-79 ticks to do its work, since the 30 gets ignored. to make
this work as advertised without hacking RTEMS internals, it would go
something like this:
while (1) {
if (rate_monotonic_period( period_1, 100 ) == TIMEOUT) break;
if (rate_monotonic_period( period_2, 40 ) == TIMEOUT) break;
/* do work from 0-39 ticks */
/* block until 40 ticks has passed */
if (rate_monotonic_period( period_2, 30 ) == TIMEOUT) break;
/* cancel the period so we can reset its timer */
rate_monotonic_cancel ( period_2 );
/* start a new period with 30 ticks */
rate_monotonic_period( period_2, 30 );
/* do work from 40-69 ticks */
if (rate_monotonic_period( period_2, STATUS ) == TIMEOUT) break;
rate_monotonic_cancel( period_2 );
}
but that seems terribly kludgy.
§19.3.2 of the manual states:
If the rate monotonic period is running, the calling
task will be blocked for the remainder of the
outstanding period and, upon completion of that period,
the period will be reinitiated with the specified
period.
am I just blind, or is there indeed a missing call to change
Watchdog_Control->initial to the new settings so it behaves as
advertised?
--
Aaron J. Grier | Frye Electronics, Tigard, OR | aaron at frye.com
More information about the users
mailing list