summaryrefslogtreecommitdiffstats
path: root/schedsim/shell/shared
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-05-17 19:31:16 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-05-17 19:31:16 +0000
commitac6e5c757df45281dbd9f0ba46d75075d0ddef70 (patch)
treecd510ffc474830f0a82fbcbd53cbb9f1a8c67705 /schedsim/shell/shared
parent2011-05-17 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-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.
Diffstat (limited to 'schedsim/shell/shared')
-rw-r--r--schedsim/shell/shared/Makefile.am1
-rw-r--r--schedsim/shell/shared/include/rtems/confdefs.h10
-rw-r--r--schedsim/shell/shared/lookup_task.c4
-rw-r--r--schedsim/shell/shared/main_clocktick.c2
-rw-r--r--schedsim/shell/shared/main_rtemsinit.c19
-rw-r--r--schedsim/shell/shared/main_taskcreate.c72
-rw-r--r--schedsim/shell/shared/main_taskmode.c5
7 files changed, 99 insertions, 14 deletions
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"),