summaryrefslogtreecommitdiffstats
path: root/schedsim
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2014-05-22 10:19:55 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-05-22 10:21:44 -0500
commitcc1a54a7c8b95b209a0441194fb3578d0f774389 (patch)
tree753daa6a33f7ce17db827e7c7c5f907b05276576 /schedsim
parentcpus4_affinity_case1.scen: Specify affinity in hexadecimal (diff)
downloadrtems-schedsim-cc1a54a7c8b95b209a0441194fb3578d0f774389.tar.bz2
Enhance cpus command to do validation of executing threads.
This patch enhances the cpus command such that it can take a list of expected threads to be executing and validate that they are executing on the expected cores. The cpus command was moved to the shared directory. The documentation was updated.
Diffstat (limited to 'schedsim')
-rw-r--r--schedsim/UsingTheSchedulerSimulator.txt47
-rw-r--r--schedsim/rtems/Makefile.am1
-rw-r--r--schedsim/shell/schedsim_smppriority/Makefile.am1
-rw-r--r--schedsim/shell/schedsim_smppriority_affinity/Makefile.am1
-rw-r--r--schedsim/shell/schedsim_smpsimple/Makefile.am1
-rw-r--r--schedsim/shell/schedsim_smpsimple/add_commands.c9
-rw-r--r--schedsim/shell/shared/Makefile.am1
-rw-r--r--schedsim/shell/shared/commands.c3
-rw-r--r--schedsim/shell/shared/main_dump_all_cpus.c49
-rw-r--r--schedsim/shell/shared/main_taskcreate.c15
10 files changed, 108 insertions, 20 deletions
diff --git a/schedsim/UsingTheSchedulerSimulator.txt b/schedsim/UsingTheSchedulerSimulator.txt
index 188cdd8..ca63df8 100644
--- a/schedsim/UsingTheSchedulerSimulator.txt
+++ b/schedsim/UsingTheSchedulerSimulator.txt
@@ -8,7 +8,7 @@ Using the RTEMS Scheduler Simulator
Joel Sherrill <joel.sherrill@oarcorp.com>
-1.0, 5 May 2013
+1.1, 22 May 2014
Introduction
------------
@@ -162,11 +162,25 @@ This command initializes RTEMS using the configuration provided.
task_create Command
^^^^^^^^^^^^^^^^^^^
-*Usage*: task_create name priority
+*Usage*: task_create [-tT] [-pP] [-a affinity] name priority
This command creates and starts a Classic API task with the specified name
and initial priority. It also starts the task. This is the equivalent
of the rtems_task_create and rtems_task_start Classic API directives.
+
+In SMP configurations, the -a argument can be used to specify the
+affinity of the created task if the default affinity is not desired.
+In this case, rtems_task_set_affinity is invoked between the calls
+to rtems_task_create and rtems_task_start Classic API directives.
+
+The command line arguments are processed as follows:
+
+* -t - disable timeslicing
+* -T - enable timeslicing
+* -p - disable preemption
+* -p - enable preemption
+* -a affinity - specify affinity mask
+
The following is the output from the invocation 'task_create joel 5':
-------------------------------------------------------------
@@ -249,6 +263,22 @@ This command is used to cause the currently executing task to sleep
for the specified number of ticks. It is the equivalent of the
rtems_task_wake_after directive in the Classic API.
+task_get_affinity Command
+^^^^^^^^^^^^^^^^^^^^^^^^^
+*Usage*: task_get_affinity task
+
+This command is used to print the affinity of the specified task.
+It is the equivalent of the rtems_task_get_affinity directive
+in the Classic API.
+
+task_set_affinity Command
+^^^^^^^^^^^^^^^^^^^^^^^^^
+*Usage*: task_set_affinity task affinity
+
+This command is used to modify the affinity of the specified task.
+It is the equivalent of the rtems_task_set_affinity directive
+in the Classic API.
+
clock_tick Command
^^^^^^^^^^^^^^^^^^
*Usage*: clock_tick ticks
@@ -308,6 +338,19 @@ semaphore. It is the equivalent of the rtems_semaphore_flush directive
in the Classic API.
+cpus Command
+^^^^^^^^^^^^
+*Usage*: cpus [expected0 .. expectedn]
+
+This method prints the executing and heir thread for each processor
+in the system. If provided with arguments, the argumnents may be
+task names or ids and indicate the task which is expected to be
+executing on that processor. If the expected task name/id is '-',
+then that processor is not checked.
+
+In the event that the executing thread does not match the expected,
+the scenario is aborted. This allows for self-checking scenarios.
+
executing Command
^^^^^^^^^^^^^^^^^
*Usage*: executing
diff --git a/schedsim/rtems/Makefile.am b/schedsim/rtems/Makefile.am
index 28833c1..7b14d98 100644
--- a/schedsim/rtems/Makefile.am
+++ b/schedsim/rtems/Makefile.am
@@ -175,6 +175,7 @@ librtems_a_SOURCES += $(cpukitdir)/rtems/src/clocksetnsecshandler.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/clocktick.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/clocktodtoseconds.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/clocktodvalidate.c
+librtems_a_SOURCES += $(cpukitdir)/rtems/src/getprocessorcount.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/sem.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/semcreate.c
librtems_a_SOURCES += $(cpukitdir)/rtems/src/semdata.c
diff --git a/schedsim/shell/schedsim_smppriority/Makefile.am b/schedsim/shell/schedsim_smppriority/Makefile.am
index 28ec6cf..4596b85 100644
--- a/schedsim/shell/schedsim_smppriority/Makefile.am
+++ b/schedsim/shell/schedsim_smppriority/Makefile.am
@@ -4,7 +4,6 @@ SOURCES = config.c
SOURCES += $(srcdir)/../schedsim_smpsimple/add_commands.c
SOURCES += $(srcdir)/../schedsim_smpsimple/main_current_cpu.c
SOURCES += $(srcdir)/../schedsim_smpsimple/main_dispatch.c
-SOURCES += $(srcdir)/../schedsim_smpsimple/main_dump_all_cpus.c
SOURCES += $(srcdir)/../schedsim_smpsimple/main_dump_ready_tasks.c
SOURCES += $(srcdir)/../schedsim_smpsimple/printheir_executing.c
SOURCES += $(srcdir)/../schedsim_smpsimple/smp_stub.c
diff --git a/schedsim/shell/schedsim_smppriority_affinity/Makefile.am b/schedsim/shell/schedsim_smppriority_affinity/Makefile.am
index 1c65cf2..7f25c34 100644
--- a/schedsim/shell/schedsim_smppriority_affinity/Makefile.am
+++ b/schedsim/shell/schedsim_smppriority_affinity/Makefile.am
@@ -4,7 +4,6 @@ SOURCES = config.c
SOURCES += $(srcdir)/../schedsim_smpsimple/add_commands.c
SOURCES += $(srcdir)/../schedsim_smpsimple/main_current_cpu.c
SOURCES += $(srcdir)/../schedsim_smpsimple/main_dispatch.c
-SOURCES += $(srcdir)/../schedsim_smpsimple/main_dump_all_cpus.c
SOURCES += $(srcdir)/../schedsim_smpsimple/main_dump_ready_tasks.c
SOURCES += $(srcdir)/../schedsim_smpsimple/printheir_executing.c
SOURCES += $(srcdir)/../schedsim_smpsimple/smp_stub.c
diff --git a/schedsim/shell/schedsim_smpsimple/Makefile.am b/schedsim/shell/schedsim_smpsimple/Makefile.am
index 48902b9..a931b05 100644
--- a/schedsim/shell/schedsim_smpsimple/Makefile.am
+++ b/schedsim/shell/schedsim_smpsimple/Makefile.am
@@ -4,7 +4,6 @@ schedsim_smpsimple_SOURCES += add_commands.c
schedsim_smpsimple_SOURCES += config.c
schedsim_smpsimple_SOURCES += main_current_cpu.c
schedsim_smpsimple_SOURCES += main_dispatch.c
-schedsim_smpsimple_SOURCES += main_dump_all_cpus.c
schedsim_smpsimple_SOURCES += main_dump_ready_tasks.c
schedsim_smpsimple_SOURCES += printheir_executing.c
schedsim_smpsimple_SOURCES += smp_stub.c
diff --git a/schedsim/shell/schedsim_smpsimple/add_commands.c b/schedsim/shell/schedsim_smpsimple/add_commands.c
index e95f395..ad1dde2 100644
--- a/schedsim/shell/schedsim_smpsimple/add_commands.c
+++ b/schedsim/shell/schedsim_smpsimple/add_commands.c
@@ -18,7 +18,6 @@
#include "rtems_sched.h"
extern int main_dump_ready_tasks(int argc, char **argv);
-extern int main_dump_all_cpus(int argc, char **argv);
extern int main_set_current_cpu(int argc, char **argv);
extern int main_dispatch(int argc, char **argv);
@@ -35,14 +34,6 @@ void add_commands(void)
assert( cmd );
cmd = rtems_shell_add_cmd(
- "cpus",
- "rtems",
- "no args",
- main_dump_all_cpus
- );
- assert( cmd );
-
- cmd = rtems_shell_add_cmd(
"current_cpu",
"rtems",
"number",
diff --git a/schedsim/shell/shared/Makefile.am b/schedsim/shell/shared/Makefile.am
index 85b58af..eb41f4f 100644
--- a/schedsim/shell/shared/Makefile.am
+++ b/schedsim/shell/shared/Makefile.am
@@ -28,6 +28,7 @@ libschedsim_a_SOURCES += commands.c
libschedsim_a_SOURCES += getopt.c
libschedsim_a_SOURCES += lookup_semaphore.c
libschedsim_a_SOURCES += lookup_task.c
+libschedsim_a_SOURCES += main_dump_all_cpus.c
libschedsim_a_SOURCES += main_echo.c
libschedsim_a_SOURCES += main_executing.c
libschedsim_a_SOURCES += main_heir.c
diff --git a/schedsim/shell/shared/commands.c b/schedsim/shell/shared/commands.c
index 0c5ae48..7132841 100644
--- a/schedsim/shell/shared/commands.c
+++ b/schedsim/shell/shared/commands.c
@@ -30,7 +30,6 @@ extern rtems_shell_cmd_t rtems_shell_TASK_WAKE_AFTER_Command;
extern rtems_shell_cmd_t rtems_shell_CLOCK_TICK_Command;
-
extern rtems_shell_cmd_t rtems_shell_SEMAPHORE_CREATE_Command;
extern rtems_shell_cmd_t rtems_shell_SEMAPHORE_DELETE_Command;
extern rtems_shell_cmd_t rtems_shell_SEMAPHORE_OBTAIN_Command;
@@ -39,6 +38,7 @@ extern rtems_shell_cmd_t rtems_shell_SEMAPHORE_FLUSH_Command;
extern rtems_shell_cmd_t rtems_shell_TASK_EXECUTING_Command;
extern rtems_shell_cmd_t rtems_shell_TASK_HEIR_Command;
+extern rtems_shell_cmd_t rtems_shell_CPUS_Command;
rtems_shell_cmd_t *rtems_shell_Initial_commands[] = {
/* Generic Commands */
@@ -70,6 +70,7 @@ rtems_shell_cmd_t *rtems_shell_Initial_commands[] = {
/* RTEMS Helper Commands */
&rtems_shell_TASK_EXECUTING_Command,
&rtems_shell_TASK_HEIR_Command,
+ &rtems_shell_CPUS_Command,
NULL
};
diff --git a/schedsim/shell/shared/main_dump_all_cpus.c b/schedsim/shell/shared/main_dump_all_cpus.c
index dfe3bc6..1c141e1 100644
--- a/schedsim/shell/shared/main_dump_all_cpus.c
+++ b/schedsim/shell/shared/main_dump_all_cpus.c
@@ -15,8 +15,8 @@
#include "shell.h"
#include "rtems_sched.h"
+#include "schedsim_shell.h"
-// #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
#include <rtems.h>
#include <rtems/score/percpu.h>
#include <rtems/score/smp.h>
@@ -28,12 +28,14 @@ int main_dump_all_cpus(int argc, char **argv)
Thread_Control *h;
Thread_Control *i;
Thread_Control *e;
+ rtems_id id;
+ bool mismatch;
printf(
"=== CPU Status\n"
" EXECUTING / HEIR / SWITCH NEEDED\n"
);
- for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) {
+ for ( cpu=0 ; cpu < rtems_get_processor_count() ; cpu++ ) {
e = _Per_CPU_Information[cpu].per_cpu.executing;
h = _Per_CPU_Information[cpu].per_cpu.heir;
printf(
@@ -47,5 +49,48 @@ int main_dump_all_cpus(int argc, char **argv)
}
printf( "=== End of Ready Set of Threads\n" );
+ /*
+ * If no arguments, then we were not requested to verify task placement.
+ */
+ if ( argc == 1 )
+ return 0;
+
+ /*
+ * Now verify the thread on each processor.
+ */
+ mismatch = false;
+ for ( cpu=0 ; cpu < rtems_get_processor_count() ; cpu++ ) {
+ e = _Per_CPU_Information[cpu].per_cpu.executing;
+
+ if ( argv[cpu + 1][ 0 ] == '-' )
+ continue;
+
+ if ( lookup_task( argv[cpu + 1], &id ) )
+ return -1;
+
+ if ( e->Object.id != id ) {
+ mismatch = true;
+ printf(
+ "*** ERROR on CPU %d Expected 0x%08x found 0x%08x executing\n",
+ cpu,
+ id,
+ e->Object.id
+ );
+ }
+ }
+ if ( mismatch ) {
+ printf( "Exiting test scenario due to scheduling failure\n" );
+ exit( 1 );
+ }
+
return 0;
}
+
+rtems_shell_cmd_t rtems_shell_CPUS_Command = {
+ "cpus", /* name */
+ "cpus [tasks expected on cores]", /* usage */
+ "rtems", /* topic */
+ main_dump_all_cpus, /* command */
+ NULL, /* alias */
+ NULL /* next */
+};
diff --git a/schedsim/shell/shared/main_taskcreate.c b/schedsim/shell/shared/main_taskcreate.c
index 8bd8819..6f82092 100644
--- a/schedsim/shell/shared/main_taskcreate.c
+++ b/schedsim/shell/shared/main_taskcreate.c
@@ -13,8 +13,10 @@
#include "config.h"
#endif
+#if defined(RTEMS_SMP)
#define _GNU_SOURCE
#include <sys/cpuset.h>
+#endif
#include <stdio.h>
@@ -62,18 +64,20 @@ int rtems_shell_main_task_create(
char option;
int arg;
unsigned long affinity;
+#if defined(RTEMS_SMP)
cpu_set_t cpuset;
- bool do_affinity;
+ bool do_affinity = false;
+#endif
CHECK_RTEMS_IS_UP();
mode = 0;
mask = 0;
- do_affinity = false;
memset(&getopt_reent, 0, sizeof(getopt_data));
while ( (option = getopt_r( argc, argv, "a:tTpP", &getopt_reent)) != -1 ) {
switch (option) {
case 'a':
+#if defined(RTEMS_SMP)
c_p = getopt_reent.optarg;
if ( rtems_string_to_unsigned_long( c_p, &affinity, NULL, 0) ) {
fprintf( stderr, "Affinity (%s) is not a number\n", argv[2] );
@@ -83,6 +87,9 @@ int rtems_shell_main_task_create(
CPU_ZERO( &cpuset );
cpuset.__bits[0] = affinity;
+#else
+ printf( "Ignoring affinity request on uniprocessor\n" );
+#endif
break;
case 't':
@@ -102,7 +109,7 @@ int rtems_shell_main_task_create(
mode = (mode & ~RTEMS_PREEMPT_MASK) | RTEMS_PREEMPT;
break;
default:
- fprintf( stderr, "%s: Usage [-tTpP]\n", argv[0] );
+ fprintf( stderr, "%s: Usage [-a:tTpP]\n", argv[0] );
return -1;
}
}
@@ -154,6 +161,7 @@ int rtems_shell_main_task_create(
priority
);
+#if defined(RTEMS_SMP)
/*
* If specified, set the affinity
*/
@@ -173,6 +181,7 @@ int rtems_shell_main_task_create(
}
printf("Task (0x%08x) Set affinity=0x%08x\n", id, cpuset.__bits[0] );
}
+#endif
/*
* Starting the task