when does rtems_rate_monotonic_period return TIMEOUT ?

Gedare Bloom gedare at gwmail.gwu.edu
Mon Sep 19 15:39:08 UTC 2011


Your code is a little unusual. Normally you would do something like:

rtems_task Task_RM( ... ) {
   ...
   rtems_rate_monotonic_create();

  while (1) {
    status = rtems_rate_monotonic_period();
    ...
    PERIODIC_JOB_CODE
    ...
  }

At the start of every iteration of the while loop the
rtems_rate_monotonic_period will either block the task until the
timeout occurs or return immediately with status == RTEMS_TIMEOUT if
the task missed its period (ran past its deadline).

So you might do something like:
  while (1) {
    if ( rtems_rate_monotonic_period(...) == RTEMS_TIMEOUT ) {
      DEADLINE_MISS_CODE
    }
    PERIODIC_JOB_CODE
  }

Basically, each call to period() sleeps on a timer that was set by the
last call (in case of deadline overrun no sleeping occurs) and sets a
new timer equal to the period duration when the previous period
expires.

Good luck!
Gedare

On Sun, Sep 18, 2011 at 1:29 PM, Asma Mehiaoui <asma.mehiaoui at yahoo.com> wrote:
> Hello,
>
> I'm runing this code of periodic task with rate monotonic period.  I would
> like to test the case where task missed it's period, could someone help me
> to do it ?
> I tried to put a loop within but that does not work (the loop does not
> end).
> What does RTEMS do when rtems_rate_monotonic_period return TIMEOUT ?
>
> rtems_task Task_Rate_Monotonic_Period(
>   rtems_task_argument unused
> )
> {
>   rtems_time_of_day time;
>   rtems_status_code status;
>   uint32_t          ticks_since_boot;
>   rtems_name        my_period_name;
>   rtems_id          RM_period;
>   bool              is_RM_created = 0;
>   uint32_t          count;
>
>   while( 1 ) {
>     status = rtems_clock_get_tod( &time );
>     printf( "\n\nTask 2 - activating every %d second using rate monotonic
> manager to schedule (rtems_rate_monotonic_period)\n",
> PERIOD_TASK_RATE_MONOTONIC);
>     print_time( " - rtems_clock_get_tod - ", &time, "\n" );
>     ticks_since_boot = rtems_clock_get_ticks_since_boot();
>     printf(" - Ticks since boot: %" PRIu32 "\n", ticks_since_boot);
>     if( TRUE != is_RM_created ) {
>       count = 0;
>       my_period_name = rtems_build_name( 'P', 'E', 'R', '1' );
>       status = rtems_rate_monotonic_create( my_period_name, &RM_period );
>       if( RTEMS_SUCCESSFUL != status ) {
>  printf("RM failed with status: %d\n", status);
>  exit(1);
>       }
>       // Initiate RM period -- every N2 seconds
>       status = rtems_rate_monotonic_period(
>         RM_period,
>         rtems_clock_get_ticks_per_second() * PERIOD_TASK_RATE_MONOTONIC
>       );
>       if( RTEMS_SUCCESSFUL != status ) {
>  printf("RM failed with status: %d\n", status);
>  exit(1);
>       }
>       is_RM_created = TRUE;
>     }
>     // Block until RM period has expired -- every N2 seconds
>     status = rtems_rate_monotonic_period(
>       RM_period,
>       rtems_clock_get_ticks_per_second() * PERIOD_TASK_RATE_MONOTONIC
>     );
>
> //###########################################
> int x = 0;
> while (x < 10000)
> {
> x++;
> }
> //###########################################
>     if( RTEMS_SUCCESSFUL != status ) {
>       if( RTEMS_TIMEOUT != status ) {
>  printf("RM missed period!\n");
>       }
>       printf("RM failed with status: %d\n", status);
>       exit(1);
>     }
>     }
>   }
> }
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-users
>
>




More information about the users mailing list