From b78e60b8f69ae6a4f1fe3e0f71c9eadffb1722e2 Mon Sep 17 00:00:00 2001 From: Petr Benes Date: Thu, 14 Apr 2011 23:45:58 +0200 Subject: [PATCH] test_edf updated, running, but not properly in the emulator There is a timing issue in the emulator, the task computations are executed in 0 ticks. Thus the test is useless so far. --- src/Makefile.omk | 2 +- src/edf/scheduler_edf.h | 1 + src/test_edf/init.c | 142 ++++++++++++++++++++++++++++++---------- src/test_edf/system.h | 97 +++++++++++++++++++++------ src/test_edf/task.c | 66 +++++++++++++------ 5 files changed, 232 insertions(+), 76 deletions(-) diff --git a/src/Makefile.omk b/src/Makefile.omk index 484a7d1..3dc974c 100644 --- a/src/Makefile.omk +++ b/src/Makefile.omk @@ -1,2 +1,2 @@ -SUBDIRS = system_opt libbar appfoo edf +SUBDIRS = system_opt libbar appfoo edf test_edf diff --git a/src/edf/scheduler_edf.h b/src/edf/scheduler_edf.h index 4b253f8..a53cc34 100644 --- a/src/edf/scheduler_edf.h +++ b/src/edf/scheduler_edf.h @@ -15,6 +15,7 @@ EDF_Chain_Control _Thread_Ready_EDF_chain; void edf_next_period(void); /// Changes scheduling policy from priorities to deadlines +/// @param __rel_deadline__ in ticks required void edf_deadline_init(uint32_t __rel_deadline__); /// Changes scheduling policy from deadlines to priorities diff --git a/src/test_edf/init.c b/src/test_edf/init.c index f117781..76cbc2e 100644 --- a/src/test_edf/init.c +++ b/src/test_edf/init.c @@ -1,62 +1,132 @@ -/* - * The EDF scheduler functionality test - * - * - * Init +/* Init * * This routine is the initialization task for this test program. - * It is a user initialization task and has the responsibility for creating - * and starting the tasks that make up the test. - * - * Input parameters: - * argument - task argument + * It is called from init_exec and has the responsibility for creating + * and starting the tasks that make up the test. If the time of day + * clock is required for the test, it should also be set to a known + * value by this function. + * + * Input parameters: NONE * * Output parameters: NONE * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * 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. + * + * $Id: init.c,v 1.12.4.1 2003/09/04 18:46:30 joel Exp $ */ -#define TEST_INIT +#define CONFIGURE_INIT +#include #include "system.h" -#define CONFIGURE_MICROSECONDS_PER_TICK RTEMS_MILLISECONDS_TO_MICROSECONDS(10) +#include "app_def.h" +#include +#include +#include +#include +#include + + +#define BUILD_VERSION_STRING(major,minor,patch) \ + __XSTRING(major) "." __XSTRING(minor) "." __XSTRING(patch) + +#define RTEMS_VER_CODE VER_CODE(__RTEMS_MAJOR__ ,__RTEMS_MINOR__ ,__RTEMS_REVISION__) + +#if RTEMS_VER_CODE < VER_CODE(4,7,99) + #define rtems_shell_add_cmd shell_add_cmd + #define rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait,m_login_check) \ + shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,B19200 | CS8,m_forever) +#elif RTEMS_VER_CODE < VER_CODE(4,9,99) + #define rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait,m_login_check) \ + rtems_shell_init(m_task_name,m_task_stacksize,m_task_priority,m_devname,m_forever,m_wait) +#endif + +void +bad_rtems_status(rtems_status_code status, int fail_level, const char *text) +{ + printf("ERROR: %s status %s", text, rtems_status_text(status)); + status = rtems_task_delete( RTEMS_SELF ); +} + +int testcmd_forshell(int argc, char **argv) +{ + int i; + printf("Command %s called\n",argv[0]); + for(i=1;i +#include /* functions */ rtems_task Init( rtems_task_argument argument ); - - -rtems_task Task_1( - rtems_task_argument argument -); -rtems_task Task_2( - rtems_task_argument argument -); - /* configuration information */ +#include /* for device driver prototypes */ + #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK + +#define TICKS_PER_SECOND 100 -#define CONFIGURE_MAXIMUM_TASKS 7 -#define CONFIGURE_MAXIMUM_PERIODS 10 +#define CONFIGURE_MAXIMUM_TIMERS 32 +#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 32 +#define CONFIGURE_MAXIMUM_SEMAPHORES 32 +#define CONFIGURE_MAXIMUM_TASKS 32 +#define CONFIGURE_MAXIMUM_PERIODS 4 +#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 2 +#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 +#define CONFIGURE_MAXIMUM_DRIVERS (CONFIGURE_NUMBER_OF_DRIVERS+10) + +#ifdef RTEMS_POSIX_API +#define CONFIGURE_MAXIMUM_POSIX_THREADS 32 +#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 20 +#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 10 +#endif /*RTEMS_POSIX_API*/ -#define CONFIGURE_INIT_TASK_PRIORITY 10 -#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES #define CONFIGURE_RTEMS_INIT_TASKS_TABLE -#define CONFIGURE_EXTRA_TASK_STACKS (6 * 3 * RTEMS_MINIMUM_STACK_SIZE) -#include +#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM +/*#define CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM*/ + +#define CONFIGURE_MICROSECONDS_PER_TICK 10000 + +#define CONFIGURE_INIT_TASK_STACK_SIZE (10*1024) +#define CONFIGURE_INIT_TASK_PRIORITY 120 +#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \ + RTEMS_NO_TIMESLICE | \ + RTEMS_NO_ASR | \ + RTEMS_INTERRUPT_LEVEL(0)) + + + +/* + * Scheduler configuration. + * + * The scheduler configuration allows an application to select the + * scheduling policy to use. The supported configurations are: + * CONFIGURE_SCHEDULER_USER - user provided scheduler + * CONFIGURE_SCHEDULER_PRIORITY - Deterministic Priority Scheduler + * + * If no configuration is specified by the application, then + * CONFIGURE_SCHEDULER_PRIORITY is assumed to be the default. + * + * An application can define its own scheduling policy by defining + * CONFIGURE_SCHEDULER_USER and the following: + * - CONFIGURE_SCHEDULER_ENTRY_POINTS + * - CONFIGURE_MEMORY_FOR_SCHEDULER - base memory + * - CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER - per task memory + */ + +/// Enable yur own scheduler +#define CONFIGURE_SCHEDULER_USER + +/** + * EDF scheduler configuration. + */ +#ifdef CONFIGURE_SCHEDULER_USER + #define CONFIGURE_SCHEDULER_USER_ENTRY_POINTS + #include "scheduler_edf.h" + #define SCHEDULER_ENTRY_POINTS SCHEDULER_EDF_ENTRY_POINTS + #define CONFIGURE_MEMORY_FOR_SCHEDULER (_Configure_From_workspace(sizeof(EDF_Chain_Control))) + #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER (_Configure_From_workspace(sizeof(RBT_Node))) +#endif + + + +#include + -/* global variables */ -TEST_EXTERN rtems_id Task_id[ 7 ]; /* array of task ids */ -TEST_EXTERN rtems_name Task_name[ 7 ]; /* array of task names */ /* end of include file */ diff --git a/src/test_edf/task.c b/src/test_edf/task.c index 7152ca4..27a10eb 100644 --- a/src/test_edf/task.c +++ b/src/test_edf/task.c @@ -1,4 +1,21 @@ +#include #include "system.h" +#include "app_def.h" +#include +#include +#include +#include +#include +#include +#include + + +#define TEST_DURATION 130 + +#define T1_DUR 400000000 +#define T2_DUR 600000000 +#define T1_PER 7 +#define T2_PER 10 rtems_task Task_1( rtems_task_argument argument @@ -9,27 +26,29 @@ rtems_task Task_1( rtems_status_code status; char output1[50]; char output2[50]; - unsigned32 start, stop, period_length, max_i, max_j; - unsigned32 i,j,k,l; + unsigned int start, stop, period_length, max_i, max_j; + unsigned int i,j,k; name = rtems_build_name( 'P', 'E', 'R', 'A' ); status = rtems_rate_monotonic_create( name, &period ); + if ( status != RTEMS_SUCCESSFUL ) { printf( "rtems_monotonic_create failed with status of %d.\n", status); exit( 1 ); } - period_length = 7; - max_i = 10000; max_j = 4000; + period_length = T1_PER; // duration 3 ticks + max_i = 10000; max_j = T1_DUR; + edf_deadline_init(period_length); while ( 1 ) { if (rtems_rate_monotonic_period(period,period_length)==RTEMS_TIMEOUT) puts("P1 - Deadline miss"); - + edf_next_period(); rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start); - sprintf(output1,"P1-S ticks:%d",start); + sprintf(output1,"P1-S ticks:%u",start); puts(output1); - if ( start >= 30 ) break; + if ( start >= TEST_DURATION ) break; /* active computing */ for ( i = 1 ; i < max_i; i++) @@ -43,21 +62,25 @@ rtems_task Task_1( } rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop); - sprintf(output2,"P1-F ticks:%d",stop); + sprintf(output2,"P1-F ticks:%u",stop); puts(output2); } /* missed period so delete period and SELF */ status = rtems_rate_monotonic_delete( period ); + edf_deadline_cancel(); if ( status != RTEMS_SUCCESSFUL ) { printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status ); - rtems_test_exit( 0 ); + exit( 0 ); } puts( "*** END OF TEST - edf***" ); - rtems_test_exit( 0 ); + exit( 0 ); } + + + rtems_task Task_2( rtems_task_argument argument ) @@ -67,8 +90,8 @@ rtems_task Task_2( rtems_status_code status; char output1[50]; char output2[50]; - unsigned32 start, stop, period_length, max_i, max_j; - unsigned32 i,j,k,l; + unsigned int start, stop, period_length, max_i, max_j; + unsigned int i,j,k; name = rtems_build_name( 'P', 'E', 'R', 'B' ); status = rtems_rate_monotonic_create( name, &period ); @@ -77,17 +100,18 @@ rtems_task Task_2( exit( 1 ); } - period_length = 10; - max_i = 10000; max_j = 6000; + period_length = T2_PER; // duration 5 ticks + max_i = 10000; max_j = T2_DUR; + edf_deadline_init(period_length); while ( 1 ) { if (rtems_rate_monotonic_period(period,period_length)==RTEMS_TIMEOUT) puts("P2 - Deadline miss"); - + edf_next_period(); rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start); - sprintf(output1,"P2-S ticks:%d",start); + sprintf(output1,"P2-S ticks:%u",start); puts(output1); - if ( _Watchdog_Ticks_since_boot >= 30 ) { + if ( _Watchdog_Ticks_since_boot >= TEST_DURATION ) { break; } @@ -104,17 +128,19 @@ rtems_task Task_2( } rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop); - sprintf(output2,"P2-F ticks:%d",stop); + sprintf(output2,"P2-F ticks:%u",stop); puts(output2); } /* missed period so delete period and SELF */ status = rtems_rate_monotonic_delete( period ); + edf_deadline_cancel(); if ( status != RTEMS_SUCCESSFUL ) { printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status ); - rtems_test_exit( 0 ); + exit( 0 ); } puts( "*** END OF TEST - edf***" ); - rtems_test_exit( 0 ); + exit( 0 ); } + -- 2.39.2