summaryrefslogtreecommitdiffstats
path: root/schedsim/shell/shared
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/shell/shared
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/shell/shared')
-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
4 files changed, 62 insertions, 6 deletions
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