Changeset 166a9f6 in rtems


Ignore:
Timestamp:
Jan 30, 2017, 6:34:28 PM (3 years ago)
Author:
Kuan-Hsun Chen <c0066c@…>
Branches:
5, master
Children:
70488f5
Parents:
c5430e06
git-author:
Kuan-Hsun Chen <c0066c@…> (01/30/17 18:34:28)
git-committer:
Sebastian Huber <sebastian.huber@…> (01/31/17 06:20:06)
Message:

sprmsched01/spedfsched04: Revise

Instead of using the target time and console driver, both tests now use
assertions and rtems_rate_monotonic_get_status() to verify the count of
postponed jobs. The setting of spedfsched04 is slightly changed.

Close #2795.

Location:
testsuites/sptests
Files:
6 edited

Legend:

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

    rc5430e06 r166a9f6  
    11
    22rtems_tests_PROGRAMS = spedfsched04
    3 spedfsched04_SOURCES = init.c
     3spedfsched04_SOURCES = init.c ../../support/src/spin.c
    44       
    55dist_rtems_tests_DATA = spedfsched04.scn
  • testsuites/sptests/spedfsched04/init.c

    rc5430e06 r166a9f6  
    11/**
    2  * @brief A heuristic example to demonstrate how the postponed jobs are handled.
     2 * @brief A heuristic example to demonstrate how the postponed jobs are handled in EDF.
    33 *
    44 * 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.
     5 * Task 1 has (400, 500) and task 2 has (450, 550), where (required ticks, period/deadline).
     6 * For the simplicity, we only execute the first task three times.
    77 * In the original implementation in v4.11, no matter how many periods are
    88 * expired, only one job will be released with a shifted deadline assignment.
    99 *
    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.
     10 * In this example, task 2 will be blocked by the second and third jobs
     11 * of task 1, so that there are two jobs are postponed.
     12 * Due to the domino effects, the following jobs of task 2 will be postponed until Job 9.
    1313 *
    1414 * 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.
     15 * normal status at Job 9.
     16 * Otherwise, the release time of job 3 is no longer periodic
     17 * and there is no more postponed jobs.
    1718 *
    1819 */
    1920
    2021/*
    21  *  COPYRIGHT (c) 2016 Kuan-Hsun Chen.
     22 *  COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen.
    2223 *
    2324 *  The license and distribution terms for this file may be
     
    3132
    3233#include <rtems/cpuuse.h>
    33 #include <rtems/counter.h>
    34 
    35 #include <stdio.h>
    36 #include <inttypes.h>
    37 
    38 #include "tmacros.h"
     34#include <tmacros.h>
     35#include "test_support.h"
    3936
    4037const char rtems_test_name[] = "SPEDFSCHED 4";
    4138
    42 static const uint32_t Periods[] = { 5000, 6000 };
    43 static const uint32_t Iterations[] = { 4000, 4000 };
     39static const uint32_t Periods[] = { 500, 550 };
     40static const uint32_t Iterations[] = { 400, 450 };
    4441static const rtems_name Task_name[] = {
    4542  rtems_build_name( 'T', 'A', '1', ' ' ),
     
    4744};
    4845static const rtems_task_priority Prio[3] = { 2, 5 };
    49 static const uint32_t testnumber = 11; /* stop condition */
     46static const uint32_t testnumber = 9; /* stop condition */
    5047
    5148static uint32_t tsk_counter[] = { 0, 0 };
     
    5956)
    6057{
    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;
     58  rtems_status_code                         status;
     59  rtems_id                                  RM_period;
     60  rtems_id                                  selfid=rtems_task_self();
     61  rtems_rate_monotonic_period_status        period_status;
     62  uint32_t                                  flag=0;
    6663
    67   t0 = rtems_counter_nanoseconds_to_ticks( 1000000 ); //1ms ticks counter
    68   /*create period*/
     64  /* create period */
    6965  status = rtems_rate_monotonic_create( Task_name[ argument ], &RM_period );
    7066  directive_failed( status, "rtems_rate_monotonic_create" );
     
    7268  while ( FOREVER ) {
    7369    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     }
    8170
    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 );
     71    /* Do some work */
     72    rtems_test_spin_for_ticks( Iterations[ argument ] );
     73
    8974    if( argument == 1 ){
     75      if( status == RTEMS_TIMEOUT ){
     76        if( flag == 0 ){
     77          puts( "First time RTEMS_TIMEOUT" );
     78          puts( "Task 2 should have 2 postponed job due to preemption." );
     79          rtems_test_assert( period_status.postponed_jobs_count == 2 );
     80          flag = 1;
     81        }
     82      } else if ( flag == 1 && status == RTEMS_SUCCESSFUL ) {
     83        puts( "RTEMS_SUCCESSFUL" );
     84        puts( "Overrun handling is finished, now Task 2 becomes normal." );
     85        rtems_test_assert( period_status.postponed_jobs_count == 0 );
     86        flag = 0;
     87      }
     88
     89      /* Check the status */
     90      status = rtems_rate_monotonic_get_status( RM_period, &period_status );
     91      directive_failed( status, "rate_monotonic_get_status" );
     92
    9093      if( tsk_counter[ argument ] == testnumber ){
    9194        TEST_END();
     
    98101    tsk_counter[ argument ]+=1;
    99102    if ( argument == 0 ){
    100       if( tsk_counter[ argument ] == 2 ){
     103      if( tsk_counter[ argument ] == 3 ){
     104        puts("Task 1 has released 3 jobs and finished.");
    101105        status = rtems_rate_monotonic_delete( RM_period );
    102106        directive_failed( status, "rtems_rate_monotonic_delete" );
     
    117121  TEST_BEGIN();
    118122
    119   printf( "\nTicks per second in your system: %" PRIu32 "\n", rtems_clock_get_ticks_per_second() );
    120123
    121124  /* Create two tasks */
     
    127130    directive_failed( status, "rtems_task_create loop" );
    128131  }
    129 
    130132
    131133  /* After creating the periods for tasks, start to run them sequencially. */
  • testsuites/sptests/spedfsched04/spedfsched04.scn

    rc5430e06 r166a9f6  
    1 
    2 
    31*** BEGIN OF TEST SPEDFSCHED 4 ***
    4 
    5 Ticks per second in your system: 1000
    6 Job 1 Task 1 starts at tick 14.
    7                                         Job 1 Task 1 ends at tick 4023.
    8 Job 1 Task 2 starts at tick 4025.
    9 Job 2 Task 1 starts at tick 5013.
    10                                         Job 2 Task 1 ends at tick 9023.
    11                                         Job 1 Task 2 ends at tick 12045.
    12 System TIMEOUT
    13 Job 2 Task 2 starts at tick 12045.
    14                                         Job 2 Task 2 ends at tick 16054.
    15 Job 3 Task 2 starts at tick 16054.
    16                                         Job 3 Task 2 ends at tick 20061.
    17 System SUCCESSFUL
    18 Job 4 Task 2 starts at tick 22025.
    19                                         Job 4 Task 2 ends at tick 26033.
    20 Job 5 Task 2 starts at tick 28025.
    21                                         Job 5 Task 2 ends at tick 32033.
    22 Job 6 Task 2 starts at tick 34025.
    23                                         Job 6 Task 2 ends at tick 38033.
     2Task 1 has released 3 jobs and finished.
     3First time RTEMS_TIMEOUT
     4Task 2 should have 2 postponed job due to preemption.
     5RTEMS_SUCCESSFUL
     6Overrun handling is finished, now Task 2 becomes normal.
    247*** END OF TEST SPEDFSCHED 4 ***
  • testsuites/sptests/sprmsched01/Makefile.am

    rc5430e06 r166a9f6  
    11
    22rtems_tests_PROGRAMS = sprmsched01
    3 sprmsched01_SOURCES = init.c
    4        
     3sprmsched01_SOURCES = init.c ../../support/src/spin.c
     4
    55dist_rtems_tests_DATA = sprmsched01.scn
    66dist_rtems_tests_DATA += sprmsched01.doc
  • testsuites/sptests/sprmsched01/init.c

    rc5430e06 r166a9f6  
    11/**
    2  * @brief A heuristic example to demonstrate how the postponed jobs are handled.
     2 * @brief A heuristic example to demonstrate how the postponed jobs are handled in RMS.
    33 *
    44 * Given two tasks with implicit deadline under fixed-priority scheudling.
     
    2121
    2222/*
    23  *  COPYRIGHT (c) 2016 Kuan-Hsun Chen.
     23 *  COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen.
    2424 *
    2525 *  The license and distribution terms for this file may be
     
    3333
    3434#include <rtems/cpuuse.h>
    35 #include <rtems/counter.h>
    36 
    37 #include <stdio.h>
    38 #include <inttypes.h>
    39 
    40 #include "tmacros.h"
     35#include <tmacros.h>
     36#include "test_support.h"
    4137
    4238const char rtems_test_name[] = "SPRMSCHED 1";
    4339
    44 static const uint32_t Periods[] = { 10000, 2000 };
    45 static const uint32_t Iterations[] = { 6000, 1000 };
     40static const uint32_t Periods[] = { 1000, 200 };
     41static const uint32_t Iterations[] = { 600, 100 };
    4642static const rtems_name Task_name[] = {
    4743  rtems_build_name( 'T', 'A', '1', ' ' ),
     
    4945};
    5046static const rtems_task_priority Prio[3] = { 2, 5 };
    51 static const uint32_t testnumber = 11; /* stop condition */
     47static const uint32_t testnumber = 9; /* stop condition */
    5248
    5349static uint32_t tsk_counter[] = { 0, 0 };
     
    6157)
    6258{
    63   rtems_status_code status;
    64   rtems_id    RM_period;
    65   rtems_id    selfid=rtems_task_self();
    66   uint32_t    start, end, flag=0, index;
    67   rtems_counter_ticks t0;
     59  rtems_status_code                          status;
     60  rtems_id                                   RM_period;
     61  rtems_id                                   selfid=rtems_task_self();
     62  rtems_rate_monotonic_period_status         period_status;
     63  uint32_t                                   flag=0;
    6864
    69   t0 = rtems_counter_nanoseconds_to_ticks( 1000000 ); //1ms ticks counter
    7065  /*create period*/
    7166  status = rtems_rate_monotonic_create( Task_name[ argument ], &RM_period );
     
    7469  while ( FOREVER ) {
    7570    status = rtems_rate_monotonic_period( RM_period, Periods[ argument ] );
    76     //directive_failed( status, "rtems_rate_monotonic_period" ); let TIMEOUT pass
    77     if( argument == 1 && flag == 0 && status == RTEMS_TIMEOUT ){
    78       flag = 1;
    79       printf( "RTEMS_TIMEOUT\n" );
    80     } else if ( flag == 1 && status == RTEMS_SUCCESSFUL ) {
    81       flag = 0;
    82       printf( "RTEMS_SUCCESSFUL\n" );
    83     }
    8471
    85     start = rtems_clock_get_ticks_since_boot();
    86     if ( argument == 1 )
    87       printf( "Job %" PRIu32 " Task %" PRIuPTR " starts at tick %" PRIu32 ".\n", tsk_counter[ argument ]+1, argument, start );
    88     else
    89       printf( "Task %" PRIuPTR " starts at tick %" PRIu32 ".\n", argument, start );
    90     for( index = 0; index < Iterations[ argument ]; index++ ){
    91       rtems_counter_delay_ticks( t0 );
    92     }
    93     end = rtems_clock_get_ticks_since_boot();
    94     printf( "                                   Job %" PRIu32" Task %" PRIuPTR " ends at tick %" PRIu32".\n", tsk_counter[ argument ]+1, argument, end );
     72    /* Do some work */
     73    rtems_test_spin_for_ticks( Iterations[ argument ] );
     74
    9575    if( argument == 1 ){
     76      if( status == RTEMS_TIMEOUT ){
     77        if( flag == 0 ){
     78          puts( "First time RTEMS_TIMEOUT" );
     79          puts( "Task 2 should have 3 postponed jobs due to preemption." );
     80          rtems_test_assert( period_status.postponed_jobs_count == 3 );
     81          flag = 1;
     82        }
     83      } else if ( flag == 1 && status == RTEMS_SUCCESSFUL ) {
     84        puts( "RTEMS_SUCCESSFUL" );
     85        puts( "Overrun handling is finished, now Task 2 becomes normal." );
     86        rtems_test_assert( period_status.postponed_jobs_count == 0 );
     87        flag = 0;
     88      }
     89
     90      /* Check the status */
     91      status = rtems_rate_monotonic_get_status( RM_period, &period_status );
     92      directive_failed( status, "rate_monotonic_get_status" );
     93
    9694      if( tsk_counter[ argument ] == testnumber ){
    9795        TEST_END();
     
    105103    if ( argument == 0 ){
    106104      if( tsk_counter[ argument ] == 2 ){
     105        puts( "Task 1 has released two jobs" );
    107106        status = rtems_rate_monotonic_delete( RM_period );
    108107        directive_failed( status, "rtems_rate_monotonic_delete" );
     
    122121
    123122  TEST_BEGIN();
    124 
    125   printf( "\nTicks per second in your system: %" PRIu32 "\n", rtems_clock_get_ticks_per_second() );
    126123
    127124  /* Create two tasks */
  • testsuites/sptests/sprmsched01/sprmsched01.scn

    rc5430e06 r166a9f6  
    1 
    2 
    3 *** BEGIN OF TEST Rate Monotonic 01 - Overrun Test ***
    4 
    5 Ticks per second in your system: 1000
    6 Job 1 Task 1 starts at tick 13.
    7                                         Job 1 Task 1 ends at tick 6021.
    8 Job 1 Task 2 starts at tick 6022.
    9                                         Job 1 Task 2 ends at tick 7024.
    10 Job 2 Task 2 starts at tick 8022.
    11                                         Job 2 Task 2 ends at tick 9023.
    12 Job 2 Task 1 starts at tick 10013.
    13                                         Job 2 Task 1 ends at tick 16021.
    14 Job 3 Task 2 starts at tick 16023.
    15                                         Job 3 Task 2 ends at tick 17024.
    16 RTEMS_TIMEOUT
    17 Job 4 Task 2 starts at tick 17025.
    18                                         Job 4 Task 2 ends at tick 18026.
    19 Job 5 Task 2 starts at tick 18026.
    20                                         Job 5 Task 2 ends at tick 19027.
    21 Job 6 Task 2 starts at tick 19028.
    22                                         Job 6 Task 2 ends at tick 20029.
    23 Job 7 Task 2 starts at tick 20029.
    24                                         Job 7 Task 2 ends at tick 21031.
    25 Job 8 Task 2 starts at tick 21031.
    26                                         Job 8 Task 2 ends at tick 22033.
    27 Job 9 Task 2 starts at tick 22033.
    28                                         Job 9 Task 2 ends at tick 23035.
     1*** BEGIN OF TEST SPRMSCHED 1 ***
     2Task 1 has released two jobs
     3First time RTEMS_TIMEOUT
     4Task 2 should have 3 postponed jobs due to preemption.
    295RTEMS_SUCCESSFUL
    30 Job 10 Task 2 starts at tick 24022.
    31                                         Job 10 Task 2 ends at tick 25023.
    32 Job 11 Task 2 starts at tick 26022.
    33                                         Job 11 Task 2 ends at tick 27024.
    34 Job 12 Task 2 starts at tick 28022.
    35                                         Job 12 Task 2 ends at tick 29024.
    36 Job 13 Task 2 starts at tick 30022.
    37                                         Job 13 Task 2 ends at tick 31023.
    38 Job 14 Task 2 starts at tick 32022.
    39                                         Job 14 Task 2 ends at tick 33023.
    40 Job 15 Task 2 starts at tick 34022.
    41                                         Job 15 Task 2 ends at tick 35023.
    42 Job 16 Task 2 starts at tick 36022.
    43                                         Job 16 Task 2 ends at tick 37023.
    44 Period information by period
    45 --- CPU times are in seconds ---
    46 --- Wall times are in seconds ---
    47    ID     OWNER COUNT MISSED          CPU TIME                  WALL TIME
    48                                     MIN/MAX/AVG                MIN/MAX/AVG
    49 0x42010002 TA2     15      6 1.001686/7.012146/2.404131 1.001698/13.013378/5.204723
    50 *** END OF TEST Rate Monotonic 01 ***
     6Overrun handling is finished, now Task 2 becomes normal.
     7*** END OF TEST SPRMSCHED 1 ***
Note: See TracChangeset for help on using the changeset viewer.