OAR

RTEMS 4.0.0 On-Line Library


Rate Monotonic Manager Simple Periodic Task

PREV UP NEXT Bookshelf RTEMS C User's Guide

18.3.7: Simple Periodic Task

This example consists of a single periodic task which, after initialization, executes every 100 clock ticks.

rtems_task Periodic_task()
{
  rtems_name        name;
  rtems_id          period;
  rtems_status_code status;

  name = rtems_build_name( 'P', 'E', 'R', 'D' );

  (void) rate_monotonic_create( name, &period );

  while ( 1 ) {
    if ( rate_monotonic_period( period, 100 ) == TIMEOUT )
      break;

    /* Perform some periodic actions */
  }

  /* missed period so delete period and SELF */

  (void) rate_monotonic_delete( period );
  (void) task_delete( SELF );
}

The above task creates a rate monotonic period as part of its initialization. The first time the loop is executed, the rtems_rate_monotonic_period directive will initiate the period for 100 ticks and return immediately. Subsequent invocations of the rtems_rate_monotonic_period directive will result in the task blocking for the remainder of the 100 tick period. If, for any reason, the body of the loop takes more than 100 ticks to execute, the rtems_rate_monotonic_period directive will return the RTEMS_TIMEOUT status. If the above task misses its deadline, it will delete the rate monotonic period and itself.


PREV UP NEXT Bookshelf RTEMS C User's Guide

Copyright © 1988-1998 OAR Corporation