Changeset 23a11b6 in rtems


Ignore:
Timestamp:
Jan 25, 2017, 10:16:02 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
090bdc7e
Parents:
b43c2e8
Message:

sptests/spedfsched04: Merge and fix

Merge into one file and fix obvious problems (e.g. out of bounds array
access).

Update #2795.

Location:
testsuites/sptests/spedfsched04
Files:
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/spedfsched04/Makefile.am

    rb43c2e8 r23a11b6  
    11
    22rtems_tests_PROGRAMS = spedfsched04
    3 spedfsched04_SOURCES = init.c tasks.c system.h
     3spedfsched04_SOURCES = init.c
    44       
    55dist_rtems_tests_DATA = spedfsched04.scn
  • testsuites/sptests/spedfsched04/init.c

    rb43c2e8 r23a11b6  
    11/**
    2  * @file spedfsched04/init.c
     2 * @brief A heuristic example to demonstrate how the postponed jobs are handled.
    33 *
    4  * @brief A init task body for spedfsched04 example.
     4 * Given two tasks with implicit deadline under EDF policy.
     5 * Task 1 has (4, 5) and task 2 has (4, 6), where (execution time, period/deadline).
     6 * For the simplicity, we only execute the first task twice.
     7 * In the original implementation in v4.11, no matter how many periods are
     8 * expired, only one job will be released with a shifted deadline assignment.
     9 *
     10 * In this example, the first job of task 2 will be blocked by the second job
     11 * of task 1, so that there at least one following job is postponed.
     12 * Due to overhead/delay, the second following job will be postponed as well.
     13 *
     14 * If the overrun handling is correct, the period of task 2 changes back to
     15 * normal status at time 22.
     16 * Otherwise, the release time of job 3 is no longer periodic.
    517 *
    618 */
     
    1830#endif
    1931
    20 #define CONFIGURE_INIT
    21 #include "system.h"
     32#include <rtems/cpuuse.h>
     33#include <rtems/counter.h>
    2234
    23 #include <rtems/rtems/tasksimpl.h>
    24 #include <rtems/test.h>
    25 #include <rtems/status-checks.h>
     35#include <stdio.h>
     36#include <inttypes.h>
    2637
    27 const char rtems_test_name[] = "SPEDFSCHED 4 - Overrun Test";
     38#include "tmacros.h"
    2839
    29 /* Global variables */
    30 rtems_id   Task_id[ 2 ];         /* array of task ids */
    31 rtems_name Task_name[ 2 ];       /* array of task names */
    32 uint32_t tick_per_second;        /* time reference */
    33 int testnumber = 5;                  /* stop condition */
     40const char rtems_test_name[] = "SPEDFSCHED 4";
    3441
    35 rtems_task_priority Prio[ 3 ] = { 0, 2, 5 };
     42static const uint32_t Periods[] = { 5000, 6000 };
     43static const uint32_t Iterations[] = { 4000, 4000 };
     44static const rtems_name Task_name[] = {
     45  rtems_build_name( 'T', 'A', '1', ' ' ),
     46  rtems_build_name( 'T', 'A', '2', ' ' )
     47};
     48static const rtems_task_priority Prio[3] = { 2, 5 };
     49static const uint32_t testnumber = 11; /* stop condition */
    3650
    37 rtems_task Init(
     51static uint32_t tsk_counter[] = { 0, 0 };
     52static rtems_id   Task_id[ 2 ];
     53
     54/**
     55 * @brief Task body
     56 */
     57static rtems_task Task(
     58  rtems_task_argument argument
     59)
     60{
     61  rtems_status_code status;
     62  rtems_id    RM_period;
     63  rtems_id    selfid=rtems_task_self();
     64  uint32_t    start, end, flag=0, index;
     65  rtems_counter_ticks t0;
     66
     67  t0 = rtems_counter_nanoseconds_to_ticks( 1000000 ); //1ms ticks counter
     68  /*create period*/
     69  status = rtems_rate_monotonic_create( Task_name[ argument ], &RM_period );
     70  directive_failed( status, "rtems_rate_monotonic_create" );
     71
     72  while ( FOREVER ) {
     73    status = rtems_rate_monotonic_period( RM_period, Periods[ argument ] );
     74    if( flag == 0 && status == RTEMS_TIMEOUT ){
     75      flag = 1;
     76      printf( "RTEMS_TIMEOUT\n" );
     77    } else if ( flag == 1 && status == RTEMS_SUCCESSFUL ) {
     78      flag = 0;
     79      printf( "RTEMS_SUCCESSFUL\n" );
     80    }
     81
     82    start = rtems_clock_get_ticks_since_boot();
     83    printf( "Job %" PRIu32 " Task %" PRIuPTR " starts at tick %" PRIu32 ".\n", tsk_counter[ argument ]+1, argument, start );
     84    for( index = 0; index < Iterations[ argument ]; index++ ){
     85      rtems_counter_delay_ticks( t0 );
     86    }
     87    end = rtems_clock_get_ticks_since_boot();
     88    printf( "                                   Job %" PRIu32" Task %" PRIuPTR " ends at tick %" PRIu32".\n", tsk_counter[ argument ]+1, argument, end );
     89    if( argument == 1 ){
     90      if( tsk_counter[ argument ] == testnumber ){
     91        TEST_END();
     92        status = rtems_rate_monotonic_delete( RM_period );
     93        directive_failed( status, "rtems_rate_monotonic_delete" );
     94        rtems_test_exit( 0 );
     95      }
     96    }
     97
     98    tsk_counter[ argument ]+=1;
     99    if ( argument == 0 ){
     100      if( tsk_counter[ argument ] == 2 ){
     101        status = rtems_rate_monotonic_delete( RM_period );
     102        directive_failed( status, "rtems_rate_monotonic_delete" );
     103        status = rtems_task_delete( selfid );
     104        directive_failed( status, "rtems_task_delete" );
     105      }
     106    }
     107  }
     108}
     109
     110static rtems_task Init(
    38111        rtems_task_argument argument
    39112)
    40113{
    41   uint32_t    index;
    42   TEST_BEGIN();
     114  uint32_t     index;
    43115  rtems_status_code status;
    44116
     117  TEST_BEGIN();
    45118
    46   tick_per_second = rtems_clock_get_ticks_per_second();
    47   printf( "\nTicks per second in your system: %" PRIu32 "\n", tick_per_second );
    48 
    49   Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
    50   Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
     119  printf( "\nTicks per second in your system: %" PRIu32 "\n", rtems_clock_get_ticks_per_second() );
    51120
    52121  /* Create two tasks */
    53   for ( index = 1; index <= 2; index++ ){
     122  for ( index = 0; index < RTEMS_ARRAY_SIZE(Task_name); ++index ){
    54123    status = rtems_task_create(
    55       Task_name[ index ], Prio[ index ], RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES,
     124      Task_name[ index ], Prio[index], RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES,
    56125      RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ]
    57126    );
     
    59128  }
    60129
     130
    61131  /* After creating the periods for tasks, start to run them sequencially. */
    62   for ( index = 1; index <= 2; index++ ){
     132  for ( index = 0; index < RTEMS_ARRAY_SIZE(Task_name); ++index ){
    63133    status = rtems_task_start( Task_id[ index ], Task, index);
    64     directive_failed( status, "rtems_task_start loop" );
     134    directive_failed( status, "rtems_task_start loop");
    65135  }
    66 
    67136  status = rtems_task_delete( RTEMS_SELF );
    68137  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
    69138}
    70139
     140#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
     141#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
     142#define CONFIGURE_MICROSECONDS_PER_TICK     1000
     143#define CONFIGURE_MAXIMUM_TASKS             3
     144#define CONFIGURE_MAXIMUM_PERIODS           2
     145
     146#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
     147
     148#define CONFIGURE_SCHEDULER_EDF
     149
     150#define CONFIGURE_INITIAL_EXTENSIONS \
     151  RTEMS_TEST_INITIAL_EXTENSION
     152
     153#define CONFIGURE_INIT
     154
     155#include <rtems/confdefs.h>
Note: See TracChangeset for help on using the changeset viewer.