diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-05-17 19:31:16 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-05-17 19:31:16 +0000 |
commit | ac6e5c757df45281dbd9f0ba46d75075d0ddef70 (patch) | |
tree | cd510ffc474830f0a82fbcbd53cbb9f1a8c67705 | |
parent | 2011-05-17 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-schedsim-ac6e5c757df45281dbd9f0ba46d75075d0ddef70.tar.bz2 |
2011-05-17 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am: Merge and update code. Simulators for Deterministic
Priority and SMP Simple Schedulers now work.
* run_scenarios: New file.
-rw-r--r-- | schedsim/shell/ChangeLog | 6 | ||||
-rw-r--r-- | schedsim/shell/Makefile.am | 8 | ||||
-rwxr-xr-x | schedsim/shell/run_scenarios | 90 | ||||
-rw-r--r-- | schedsim/shell/shared/Makefile.am | 1 | ||||
-rw-r--r-- | schedsim/shell/shared/include/rtems/confdefs.h | 10 | ||||
-rw-r--r-- | schedsim/shell/shared/lookup_task.c | 4 | ||||
-rw-r--r-- | schedsim/shell/shared/main_clocktick.c | 2 | ||||
-rw-r--r-- | schedsim/shell/shared/main_rtemsinit.c | 19 | ||||
-rw-r--r-- | schedsim/shell/shared/main_taskcreate.c | 72 | ||||
-rw-r--r-- | schedsim/shell/shared/main_taskmode.c | 5 |
10 files changed, 201 insertions, 16 deletions
diff --git a/schedsim/shell/ChangeLog b/schedsim/shell/ChangeLog index ca335db..6ce9f31 100644 --- a/schedsim/shell/ChangeLog +++ b/schedsim/shell/ChangeLog @@ -1,3 +1,9 @@ +2011-05-17 Joel Sherrill <joel.sherrill@oarcorp.com> + + * Makefile.am: Merge and update code. Simulators for Deterministic + Priority and SMP Simple Schedulers now work. + * run_scenarios: New file. + 2011-04-07 Joel Sherrill <joel.sherrill@oarcorp.com> * shared/main_clocktick.c, shared/main_semcreate.c, diff --git a/schedsim/shell/Makefile.am b/schedsim/shell/Makefile.am index 9cd86f5..30b2456 100644 --- a/schedsim/shell/Makefile.am +++ b/schedsim/shell/Makefile.am @@ -4,9 +4,13 @@ ACLOCAL_AMFLAGS = -I ./../aclocal -SUBDIRS = shared schedsim_priority - +SUBDIRS = shared schedsim_priority DIST_SUBDIRS = shared schedsim_priority +if HAS_SMP +SUBDIRS += schedsim_smpsimple +DIST_SUBDIRS += schedsim_smpsimple +endif + include $(top_srcdir)/../automake/subdirs.am include $(top_srcdir)/../automake/host.am diff --git a/schedsim/shell/run_scenarios b/schedsim/shell/run_scenarios new file mode 100755 index 0000000..09777f3 --- /dev/null +++ b/schedsim/shell/run_scenarios @@ -0,0 +1,90 @@ +#! /bin/sh +# +# $Id$ +# + +toggle() +{ + case $1 in + no) echo "yes" ;; + yes) echo "no" ;; + *) fatal "Unknown value to toggle ($1)" ;; + esac +} + +usage() +{ +cat <<EOF +run_scenarios [options] + -1 - toggle running single CPU scenarios (default=no) + -4 - toggle running four CPU scenarios (default=no) + -A - toggle all scenario flags +EOF +} + +vecho() +{ + if [ ${verbose} = "yes" ] ; then + echo "$*" + fi +} + +verbose=no +do_all=no +do_one=no +do_four=no +schedsim_dir= + +while getopts vd:A14 OPT +do + case "$OPT" in + v) verbose=`toggle ${verbose}` ;; + d) schedsim_dir=${OPTARG} ;; + A) do_all=`toggle ${do_all}` ;; + 1) do_one=`toggle ${do_one}` ;; + 4) do_four=`toggle ${do_four}` ;; + *) usage; exit 1; + esac +done + +if [ "X${schedsim_dir}" != "X" ] ; then + test -d ${schedsim_dir} || fatal ${schedsim_dir} is not readable + schedsim_dir=${schedsim_dir}/ +fi + +if [ ${do_all} = "yes" ]; then + SCENARIOS="scenarios/*.scen" +else + SCENARIOS= +fi + +if [ ${do_one} = "yes" ]; then + SCENARIOS="${SCENARIOS} scenarios/cpus1*.scen" +fi + +if [ ${do_four} = "yes" ]; then + SCENARIOS="${SCENARIOS} scenarios/cpus4*.scen" +fi + +for scenario in `ls -1 ${SCENARIOS}` +do + base=`echo ${scenario} | sed -s 's/\.scen$//'` + expected=${base}.expected + output=${base}.output + vecho Running ${scenario} + ${schedsim_dir}/schedsim $scenario >${output} + if [ -r ${expected} ] ; then + diff ${output} ${expected} >/dev/null + if [ $? -ne 0 ] ; then + echo "FAIL - ${scenario}" + echo " diff ${output} ${expected} " + else + echo "PASS - ${scenario}" + fi + else + echo "UNKNOWN - ${scenario}" + echo " cp ${output} ${expected} " + fi +done + + diff --git a/schedsim/shell/shared/Makefile.am b/schedsim/shell/shared/Makefile.am index 06684b4..18d5904 100644 --- a/schedsim/shell/shared/Makefile.am +++ b/schedsim/shell/shared/Makefile.am @@ -8,6 +8,7 @@ lib_LIBRARIES = libschedsim.a cpukitdir=@rtems_srcdir@/cpukit libschedsim_a_CPPFLAGS = -D__RTEMS_VIOLATE_KERNEL_VISIBILITY__ +libschedsim_a_CPPFLAGS += -I$(top_builddir)/score/include libschedsim_a_CPPFLAGS += -I$(srcdir)/sched_cpu libschedsim_a_CPPFLAGS += -I$(srcdir)/../../rtems libschedsim_a_CPPFLAGS += -I$(cpukitdir)/include diff --git a/schedsim/shell/shared/include/rtems/confdefs.h b/schedsim/shell/shared/include/rtems/confdefs.h new file mode 100644 index 0000000..3da247f --- /dev/null +++ b/schedsim/shell/shared/include/rtems/confdefs.h @@ -0,0 +1,10 @@ +/* + * $Id$ + */ + +/* + * confdefs.h is unfortunately not located in the source tree in the rtems/ + * subdirectory like it is in the installed tree. + */ + +#include <confdefs.h> diff --git a/schedsim/shell/shared/lookup_task.c b/schedsim/shell/shared/lookup_task.c index 0180886..91ab322 100644 --- a/schedsim/shell/shared/lookup_task.c +++ b/schedsim/shell/shared/lookup_task.c @@ -37,6 +37,10 @@ int METHOD_NAME( unsigned long tmp; if ( string[0] != '0' ) { + if ( !strcmp( string, "SELF" ) ) { + *id = _Thread_Executing->Object.id; + return 0; + } memset( name, '\0', sizeof(name) ); strncpy( name, string, 4 ); status = RTEMS_IDENT_NAME( diff --git a/schedsim/shell/shared/main_clocktick.c b/schedsim/shell/shared/main_clocktick.c index ab6918a..8e1f8aa 100644 --- a/schedsim/shell/shared/main_clocktick.c +++ b/schedsim/shell/shared/main_clocktick.c @@ -51,7 +51,7 @@ int rtems_shell_main_clock_tick( * Now delete the task */ for ( t=1 ; t<=ticks ; t++ ) { - fprintf( stderr, "ClockTick (%d) ...\n", t ); + printf( "ClockTick (%d) ...\n", t ); status = rtems_clock_tick(); if ( status != RTEMS_SUCCESSFUL ) { fprintf( diff --git a/schedsim/shell/shared/main_rtemsinit.c b/schedsim/shell/shared/main_rtemsinit.c index 906aa26..5580785 100644 --- a/schedsim/shell/shared/main_rtemsinit.c +++ b/schedsim/shell/shared/main_rtemsinit.c @@ -20,12 +20,29 @@ #include <rtems.h> #include "shell.h" #include <schedsim_shell.h> +#include <rtems/stringto.h> + +#if defined(RTEMS_SMP) + #include <rtems/score/smp.h> +#endif int rtems_shell_main_rtems_init( int argc, char *argv[] ) { +#if defined(RTEMS_SMP) + long cpus; + + if ( argc >= 2 ) { + if ( rtems_string_to_long(argv[1], &cpus, NULL, 0) ) { + printf( "Number of CPUs argument (%s) is not a number\n", argv[1] ); + return -1; + } + rtems_configuration_smp_maximum_processors = cpus; + } +#endif + // // Initialize RTEMS // @@ -35,7 +52,7 @@ int rtems_shell_main_rtems_init( rtems_shell_cmd_t rtems_shell_RTEMS_INIT_Command = { "rtems_init", /* name */ - "rtems_init", /* usage */ + "rtems_init [cpus]", /* usage */ "rtems", /* topic */ rtems_shell_main_rtems_init, /* command */ NULL, /* alias */ diff --git a/schedsim/shell/shared/main_taskcreate.c b/schedsim/shell/shared/main_taskcreate.c index b4fb505..017caa6 100644 --- a/schedsim/shell/shared/main_taskcreate.c +++ b/schedsim/shell/shared/main_taskcreate.c @@ -17,12 +17,28 @@ #include <stdio.h> +#define __need_getopt_newlib +#include <newlib/getopt.h> + #include <rtems.h> #include "shell.h" #include <rtems/stringto.h> #include <schedsim_shell.h> #include <rtems/error.h> +static void print_mode( + const char *prefix, + rtems_mode mode +) +{ + printf( + "%sPreemption: %s Timeslicing: %s\n", + prefix, + ((mode & RTEMS_NO_PREEMPT) ? "no" : "yes"), + ((mode & RTEMS_TIMESLICE) ? "yes" : "no") + ); +} + rtems_task dummy_task( rtems_task_argument arg ) @@ -38,15 +54,53 @@ int rtems_shell_main_task_create( rtems_id id; rtems_status_code status; long priority; + rtems_mode mode; + rtems_mode mask; + struct getopt_data getopt_reent; + char option; + int arg; CHECK_RTEMS_IS_UP(); - if (argc != 3) { - fprintf( stderr, "%s: Usage name priority\n", argv[0] ); + mode = 0; + mask = 0; + memset(&getopt_reent, 0, sizeof(getopt_data)); + while ( (option = getopt_r( argc, argv, "tTpP", &getopt_reent)) != -1 ) { + switch (option) { + case 't': + mask |= RTEMS_TIMESLICE_MASK; + mode = (mode & ~RTEMS_TIMESLICE_MASK) | RTEMS_NO_TIMESLICE; + break; + case 'T': + mask |= RTEMS_TIMESLICE_MASK; + mode = (mode & ~RTEMS_TIMESLICE_MASK) | RTEMS_TIMESLICE; + break; + case 'p': + mask |= RTEMS_PREEMPT_MASK; + mode = (mode & ~RTEMS_PREEMPT_MASK) | RTEMS_NO_PREEMPT; + break; + case 'P': + mask |= RTEMS_PREEMPT_MASK; + mode = (mode & ~RTEMS_PREEMPT_MASK) | RTEMS_PREEMPT; + break; + default: + fprintf( stderr, "%s: Usage [-tTpP]\n", argv[0] ); + return -1; + } + } + + print_mode( "Creating task with: ", mode ); + + /* + * Rest of arguments + */ + arg = getopt_reent.optind; + if ((argc - arg) != 2) { + fprintf( stderr, "%s: Usage [args] name priority\n", argv[0] ); return -1; } - if ( rtems_string_to_long(argv[2], &priority, NULL, 0) ) { + if ( rtems_string_to_long(argv[arg+1], &priority, NULL, 0) ) { printf( "Seconds argument (%s) is not a number\n", argv[1] ); return -1; } @@ -55,13 +109,13 @@ int rtems_shell_main_task_create( * Now create the task */ memset( name, '\0', sizeof(name) ); - strncpy( name, argv[1], 4 ); + strncpy( name, argv[arg], 4 ); status = rtems_task_create( rtems_build_name( name[0], name[1], name[2], name[3] ), (rtems_task_priority) priority, RTEMS_MINIMUM_STACK_SIZE, - RTEMS_DEFAULT_MODES, + mode, RTEMS_DEFAULT_ATTRIBUTES, &id ); @@ -69,7 +123,7 @@ int rtems_shell_main_task_create( fprintf( stderr, "Task Create(%s) returned %s\n", - argv[1], + name, rtems_status_text( status ) ); return -1; @@ -77,14 +131,14 @@ int rtems_shell_main_task_create( printf( "Task (%s) created: id=0x%08x, priority=%ld\n", - argv[1], + name, id, priority ); printf( "Task (%s) starting: id=0x%08x, priority=%ld\n", - argv[1], + name, id, priority ); @@ -94,7 +148,7 @@ int rtems_shell_main_task_create( fprintf( stderr, "Task Start(%s) returned %s\n", - argv[1], + name, rtems_status_text( status ) ); return -1; diff --git a/schedsim/shell/shared/main_taskmode.c b/schedsim/shell/shared/main_taskmode.c index 7b9c263..850c1f2 100644 --- a/schedsim/shell/shared/main_taskmode.c +++ b/schedsim/shell/shared/main_taskmode.c @@ -26,13 +26,12 @@ #include <schedsim_shell.h> #include <rtems/error.h> -void print_mode( +static void print_mode( const char *prefix, rtems_mode mode ) { - fprintf( - stderr, + printf( "%sPreemption: %s Timeslicing: %s\n", prefix, ((mode & RTEMS_NO_PREEMPT) ? "no" : "yes"), |