forked from Imagelibrary/rtems
committed by
Gedare Bloom
parent
3a46b72455
commit
86aa124806
@@ -37,6 +37,7 @@ _SUBDIRS += spfatal29
|
|||||||
_SUBDIRS += spmutex01
|
_SUBDIRS += spmutex01
|
||||||
_SUBDIRS += spextensions01
|
_SUBDIRS += spextensions01
|
||||||
_SUBDIRS += spsysinit01
|
_SUBDIRS += spsysinit01
|
||||||
|
_SUBDIRS += sprmsched01
|
||||||
if HAS_SMP
|
if HAS_SMP
|
||||||
else
|
else
|
||||||
_SUBDIRS += sp29
|
_SUBDIRS += sp29
|
||||||
|
|||||||
@@ -245,5 +245,6 @@ sptimer_err02/Makefile
|
|||||||
spcpuset01/Makefile
|
spcpuset01/Makefile
|
||||||
spregion_err01/Makefile
|
spregion_err01/Makefile
|
||||||
sppartition_err01/Makefile
|
sppartition_err01/Makefile
|
||||||
|
sprmsched01/Makefile
|
||||||
])
|
])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|||||||
21
testsuites/sptests/sprmsched01/Makefile.am
Normal file
21
testsuites/sptests/sprmsched01/Makefile.am
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
rtems_tests_PROGRAMS = sprmsched01
|
||||||
|
sprmsched01_SOURCES = init.c tasks.c system.h
|
||||||
|
|
||||||
|
dist_rtems_tests_DATA = sprmsched01.scn
|
||||||
|
dist_rtems_tests_DATA += sprmsched01.doc
|
||||||
|
|
||||||
|
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||||
|
include $(top_srcdir)/../automake/compile.am
|
||||||
|
include $(top_srcdir)/../automake/leaf.am
|
||||||
|
|
||||||
|
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||||
|
|
||||||
|
LINK_OBJS = $(sprmsched01_OBJECTS)
|
||||||
|
LINK_LIBS = $(sprmsched01_LDLIBS)
|
||||||
|
|
||||||
|
sprmsched01$(EXEEXT): $(sprmsched01_OBJECTS) $(sprmsched01_DEPENDENCIES)
|
||||||
|
@rm -f sprmsched01$(EXEEXT)
|
||||||
|
$(make-exe)
|
||||||
|
|
||||||
|
include $(top_srcdir)/../automake/local.am
|
||||||
70
testsuites/sptests/sprmsched01/init.c
Normal file
70
testsuites/sptests/sprmsched01/init.c
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* @file sprmsched01/init.c
|
||||||
|
*
|
||||||
|
* @brief A init task body for sprmsched01 example.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* COPYRIGHT (c) 2016 Kuan-Hsun Chen.
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rtems.com/license/LICENSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CONFIGURE_INIT
|
||||||
|
#include "system.h"
|
||||||
|
|
||||||
|
#include <rtems/rtems/tasksimpl.h>
|
||||||
|
#include <rtems/test.h>
|
||||||
|
#include <rtems/status-checks.h>
|
||||||
|
|
||||||
|
const char rtems_test_name[] = "Rate Monotonic 01 - Overrun Test";
|
||||||
|
|
||||||
|
/* Global variables */
|
||||||
|
rtems_id Task_id[ 2 ]; /* array of task ids */
|
||||||
|
rtems_name Task_name[ 2 ]; /* array of task names */
|
||||||
|
uint32_t tick_per_second; /* time reference */
|
||||||
|
int testnumber = 11; /* stop condition */
|
||||||
|
|
||||||
|
rtems_task_priority Prio[3] = { 0, 2, 5 };
|
||||||
|
|
||||||
|
rtems_task Init(
|
||||||
|
rtems_task_argument argument
|
||||||
|
)
|
||||||
|
{
|
||||||
|
uint32_t index;
|
||||||
|
rtems_status_code status;
|
||||||
|
|
||||||
|
TEST_BEGIN();
|
||||||
|
|
||||||
|
tick_per_second = rtems_clock_get_ticks_per_second();
|
||||||
|
printf( "\nTicks per second in your system: %" PRIu32 "\n", tick_per_second );
|
||||||
|
|
||||||
|
Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
|
||||||
|
Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
|
||||||
|
|
||||||
|
/* Create two tasks */
|
||||||
|
for ( index = 1; index <= 2; index++ ){
|
||||||
|
status = rtems_task_create(
|
||||||
|
Task_name[ index ], Prio[index], RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES,
|
||||||
|
RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ index ]
|
||||||
|
);
|
||||||
|
directive_failed( status, "rtems_task_create loop" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* After creating the periods for tasks, start to run them sequencially. */
|
||||||
|
for ( index = 1; index <= 2; index++ ){
|
||||||
|
status = rtems_task_start( Task_id[ index ], Task, index);
|
||||||
|
directive_failed( status, "rtems_task_start loop");
|
||||||
|
}
|
||||||
|
status = rtems_task_delete( RTEMS_SELF );
|
||||||
|
directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
|
||||||
|
}
|
||||||
|
|
||||||
33
testsuites/sptests/sprmsched01/sprmsched01.doc
Normal file
33
testsuites/sptests/sprmsched01/sprmsched01.doc
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#
|
||||||
|
# COPYRIGHT (c) 2016 Kuan-Hsun Chen.
|
||||||
|
#
|
||||||
|
# The license and distribution terms for this file may be
|
||||||
|
# found in the file LICENSE in this distribution or at
|
||||||
|
# http://www.rtems.com/license/LICENSE.
|
||||||
|
#
|
||||||
|
|
||||||
|
This file describes the directives and concepts tested by this test set.
|
||||||
|
|
||||||
|
test set name: sprmsched01
|
||||||
|
|
||||||
|
directives:
|
||||||
|
|
||||||
|
- rtems_rate_monotonic_report_statistics()
|
||||||
|
- rtems_rate_monotonic_period()
|
||||||
|
- rtems_rate_monotonic_Postponed_num()
|
||||||
|
- _Rate_monotonic_Timeout()
|
||||||
|
- _Rate_monotonic_Renew_deadline()
|
||||||
|
- _Rate_monotonic_Release_postponedjob()
|
||||||
|
- _Rate_monotonic_Block_while_expired()
|
||||||
|
|
||||||
|
|
||||||
|
concepts:
|
||||||
|
|
||||||
|
- Verify that watchdog deadline is renewed on time without shift via
|
||||||
|
_Rate_monotonic_Renew_deadline().
|
||||||
|
- Verify that postponed jobs are released with a correct number via
|
||||||
|
_Rate_monotonic_Release_postponedjob().
|
||||||
|
- Verify that rtems_rate_monotonic_report_statistics() reports correct number
|
||||||
|
of deadline misses.
|
||||||
|
- Verify that rtems_rate_monotonic_period() and
|
||||||
|
_Rate_monotonic_Block_while_expired() are operational.
|
||||||
50
testsuites/sptests/sprmsched01/sprmsched01.scn
Normal file
50
testsuites/sptests/sprmsched01/sprmsched01.scn
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
|
||||||
|
|
||||||
|
*** BEGIN OF TEST Rate Monotonic 01 - Overrun Test ***
|
||||||
|
|
||||||
|
Ticks per second in your system: 1000
|
||||||
|
Job 1 Task 1 starts at tick 13.
|
||||||
|
Job 1 Task 1 ends at tick 6021.
|
||||||
|
Job 1 Task 2 starts at tick 6022.
|
||||||
|
Job 1 Task 2 ends at tick 7024.
|
||||||
|
Job 2 Task 2 starts at tick 8022.
|
||||||
|
Job 2 Task 2 ends at tick 9023.
|
||||||
|
Job 2 Task 1 starts at tick 10013.
|
||||||
|
Job 2 Task 1 ends at tick 16021.
|
||||||
|
Job 3 Task 2 starts at tick 16023.
|
||||||
|
Job 3 Task 2 ends at tick 17024.
|
||||||
|
RTEMS_TIMEOUT
|
||||||
|
Job 4 Task 2 starts at tick 17025.
|
||||||
|
Job 4 Task 2 ends at tick 18026.
|
||||||
|
Job 5 Task 2 starts at tick 18026.
|
||||||
|
Job 5 Task 2 ends at tick 19027.
|
||||||
|
Job 6 Task 2 starts at tick 19028.
|
||||||
|
Job 6 Task 2 ends at tick 20029.
|
||||||
|
Job 7 Task 2 starts at tick 20029.
|
||||||
|
Job 7 Task 2 ends at tick 21031.
|
||||||
|
Job 8 Task 2 starts at tick 21031.
|
||||||
|
Job 8 Task 2 ends at tick 22033.
|
||||||
|
Job 9 Task 2 starts at tick 22033.
|
||||||
|
Job 9 Task 2 ends at tick 23035.
|
||||||
|
RTEMS_SUCCESSFUL
|
||||||
|
Job 10 Task 2 starts at tick 24022.
|
||||||
|
Job 10 Task 2 ends at tick 25023.
|
||||||
|
Job 11 Task 2 starts at tick 26022.
|
||||||
|
Job 11 Task 2 ends at tick 27024.
|
||||||
|
Job 12 Task 2 starts at tick 28022.
|
||||||
|
Job 12 Task 2 ends at tick 29024.
|
||||||
|
Job 13 Task 2 starts at tick 30022.
|
||||||
|
Job 13 Task 2 ends at tick 31023.
|
||||||
|
Job 14 Task 2 starts at tick 32022.
|
||||||
|
Job 14 Task 2 ends at tick 33023.
|
||||||
|
Job 15 Task 2 starts at tick 34022.
|
||||||
|
Job 15 Task 2 ends at tick 35023.
|
||||||
|
Job 16 Task 2 starts at tick 36022.
|
||||||
|
Job 16 Task 2 ends at tick 37023.
|
||||||
|
Period information by period
|
||||||
|
--- CPU times are in seconds ---
|
||||||
|
--- Wall times are in seconds ---
|
||||||
|
ID OWNER COUNT MISSED CPU TIME WALL TIME
|
||||||
|
MIN/MAX/AVG MIN/MAX/AVG
|
||||||
|
0x42010002 TA2 15 6 1.001686/7.012146/2.404131 1.001698/13.013378/5.204723
|
||||||
|
*** END OF TEST Rate Monotonic 01 ***
|
||||||
61
testsuites/sptests/sprmsched01/system.h
Normal file
61
testsuites/sptests/sprmsched01/system.h
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/**
|
||||||
|
* @file sprmsched01/system.h
|
||||||
|
*
|
||||||
|
* @brief sprmsched01 example header
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* COPYRIGHT (c) 1989-2007.
|
||||||
|
* On-Line Applications Research Corporation (OAR).
|
||||||
|
*
|
||||||
|
* COPYRIGHT (c) 2016 Kuan-Hsun Chen.
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rtems.com/license/LICENSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <rtems.h>
|
||||||
|
|
||||||
|
#include <tmacros.h>
|
||||||
|
|
||||||
|
/* function prototypes */
|
||||||
|
|
||||||
|
rtems_task Init(
|
||||||
|
rtems_task_argument argument
|
||||||
|
);
|
||||||
|
|
||||||
|
rtems_task Task(
|
||||||
|
rtems_task_argument argument
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Keep the names and IDs in global variables so another task can use them.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern rtems_id Task_id[ 2 ]; /* array of task ids */
|
||||||
|
extern rtems_name Task_name[ 2 ]; /* array of task names */
|
||||||
|
extern uint32_t tick_per_second; /* time reference */
|
||||||
|
extern int testnumber; /* stop condition */
|
||||||
|
|
||||||
|
/* configuration information */
|
||||||
|
|
||||||
|
#include <bsp.h> /* for device driver prototypes */
|
||||||
|
|
||||||
|
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||||
|
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||||
|
#define CONFIGURE_MICROSECONDS_PER_TICK 1000 // NB: 10 and lower gives system failure for erc32 simulator
|
||||||
|
#define CONFIGURE_MAXIMUM_TASKS 3
|
||||||
|
#define CONFIGURE_MAXIMUM_SEMAPHORES 1
|
||||||
|
#define CONFIGURE_MAXIMUM_PRIORITY 15
|
||||||
|
#define CONFIGURE_EXTRA_TASK_STACKS (20 * RTEMS_MINIMUM_STACK_SIZE)
|
||||||
|
#define CONFIGURE_MAXIMUM_PERIODS 3
|
||||||
|
|
||||||
|
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||||
|
|
||||||
|
#include <rtems/confdefs.h>
|
||||||
|
|
||||||
|
/* end of include file */
|
||||||
112
testsuites/sptests/sprmsched01/tasks.c
Normal file
112
testsuites/sptests/sprmsched01/tasks.c
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
/**
|
||||||
|
* @file sprmsched01/tasks.c
|
||||||
|
*
|
||||||
|
* @brief A heuristic example to demonstrate how the postponed jobs are handled.
|
||||||
|
*
|
||||||
|
* Given two tasks with implicit deadline under fixed-priority scheudling.
|
||||||
|
* Task 1 has (6, 10) and task 2 has (1, 2), where (execution time, deadline/period).
|
||||||
|
* To force deadline misses, we reverse the rate-monotonic priority assignment
|
||||||
|
* and only execute the highest priority task twice.
|
||||||
|
*
|
||||||
|
* In the original implementation in v4.11, no matter how many periods are
|
||||||
|
* expired, RMS manager only releases a job with a shifted deadline assignment
|
||||||
|
* in the watchdog. As the results written in sprmsched01.scn, we can see that
|
||||||
|
* the timeout of task 2 period will be detected right after Job3 of Task2 is finished.
|
||||||
|
* If the overrun handling is correct, the status of task 2 period will return back to
|
||||||
|
* RTEMS_SUCCESSFUL after periodically releasing those postponed jobs (the last one is Job 9).
|
||||||
|
*
|
||||||
|
* Otherwise, we can see that the release time of Job 4 is no longer periodic,
|
||||||
|
* and the RTEMS returns back to RTEMS_SUCCESSFUL right after Job 4 is finished
|
||||||
|
* without releasing all the other postponed jobs.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* COPYRIGHT (c) 2016 Kuan-Hsun Chen.
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rtems.com/license/LICENSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "system.h"
|
||||||
|
|
||||||
|
/* CPU usage and Rate monotonic manger statistics */
|
||||||
|
#include "rtems/cpuuse.h"
|
||||||
|
#include "rtems/counter.h"
|
||||||
|
|
||||||
|
/* Periods for the various tasks [ticks] */
|
||||||
|
uint32_t Periods[3] = { 0, 10000, 2000 };
|
||||||
|
uint32_t Iterations[3] = { 0, 6000, 1000 };
|
||||||
|
uint32_t tsk_counter[3] = { 0, 0, 0 };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Task body
|
||||||
|
*/
|
||||||
|
rtems_task Task(
|
||||||
|
rtems_task_argument argument
|
||||||
|
)
|
||||||
|
{
|
||||||
|
rtems_status_code status;
|
||||||
|
rtems_id RM_period;
|
||||||
|
rtems_id selfid=rtems_task_self();
|
||||||
|
uint32_t start, end, flag=0, index;
|
||||||
|
rtems_counter_ticks t0;
|
||||||
|
|
||||||
|
t0 = rtems_counter_nanoseconds_to_ticks( 1000000 ); //1ms ticks counter
|
||||||
|
/*create period*/
|
||||||
|
status = rtems_rate_monotonic_create( argument, &RM_period );
|
||||||
|
directive_failed( status, "rtems_rate_monotonic_create" );
|
||||||
|
|
||||||
|
switch ( argument ) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
while ( FOREVER ) {
|
||||||
|
status = rtems_rate_monotonic_period( RM_period, Periods[ argument ] );
|
||||||
|
//directive_failed( status, "rtems_rate_monotonic_period" ); let TIMEOUT pass
|
||||||
|
if( argument == 2 && flag == 0 && status == RTEMS_TIMEOUT ){
|
||||||
|
flag = 1;
|
||||||
|
printf( "RTEMS_TIMEOUT\n" );
|
||||||
|
} else if ( flag == 1 && status == RTEMS_SUCCESSFUL ) {
|
||||||
|
flag = 0;
|
||||||
|
printf( "RTEMS_SUCCESSFUL\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
start = rtems_clock_get_ticks_since_boot();
|
||||||
|
if ( argument == 2 )
|
||||||
|
printf( "Job %d Task %d starts at tick %d.\n", tsk_counter[ argument ]+1, argument, start );
|
||||||
|
else
|
||||||
|
printf( "Task %d starts at tick %d.\n", argument, start );
|
||||||
|
for( index = 0; index < Iterations[ argument ]; index++ ){
|
||||||
|
rtems_counter_delay_ticks( t0 );
|
||||||
|
}
|
||||||
|
end = rtems_clock_get_ticks_since_boot();
|
||||||
|
printf( " Job %d Task %d ends at tick %d.\n", tsk_counter[ argument ]+1, argument, end );
|
||||||
|
if( argument == 2 ){
|
||||||
|
if( tsk_counter[ argument ] == testnumber ){
|
||||||
|
TEST_END();
|
||||||
|
status = rtems_rate_monotonic_delete( RM_period );
|
||||||
|
directive_failed( status, "rtems_rate_monotonic_delete" );
|
||||||
|
rtems_test_exit( 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tsk_counter[ argument ]+=1;
|
||||||
|
if ( argument == 1 ){
|
||||||
|
if( tsk_counter[ argument ] == 2 ){
|
||||||
|
status = rtems_rate_monotonic_delete( RM_period );
|
||||||
|
directive_failed( status, "rtems_rate_monotonic_delete" );
|
||||||
|
status = rtems_task_delete( selfid );
|
||||||
|
directive_failed( status, "rtems_task_delete" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user