Index: schedsim/UsingTheSchedulerSimulator.txt
===================================================================
--- schedsim/UsingTheSchedulerSimulator.txt	(revision 4350081f85da91dd70cedde7f1fc086842b445f8)
+++ schedsim/UsingTheSchedulerSimulator.txt	(revision cc1a54a7c8b95b209a0441194fb3578d0f774389)
@@ -9,5 +9,5 @@
 Joel Sherrill <joel.sherrill@oarcorp.com>
 
-1.0, 5 May 2013
+1.1, 22 May 2014
 
 Introduction
@@ -163,9 +163,23 @@
 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,4 +263,20 @@
 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
@@ -308,4 +338,17 @@
 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
Index: schedsim/rtems/Makefile.am
===================================================================
--- schedsim/rtems/Makefile.am	(revision 4350081f85da91dd70cedde7f1fc086842b445f8)
+++ schedsim/rtems/Makefile.am	(revision cc1a54a7c8b95b209a0441194fb3578d0f774389)
@@ -176,4 +176,5 @@
 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
Index: schedsim/shell/schedsim_smppriority/Makefile.am
===================================================================
--- schedsim/shell/schedsim_smppriority/Makefile.am	(revision 4350081f85da91dd70cedde7f1fc086842b445f8)
+++ schedsim/shell/schedsim_smppriority/Makefile.am	(revision cc1a54a7c8b95b209a0441194fb3578d0f774389)
@@ -5,5 +5,4 @@
 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
Index: schedsim/shell/schedsim_smppriority_affinity/Makefile.am
===================================================================
--- schedsim/shell/schedsim_smppriority_affinity/Makefile.am	(revision 4350081f85da91dd70cedde7f1fc086842b445f8)
+++ schedsim/shell/schedsim_smppriority_affinity/Makefile.am	(revision cc1a54a7c8b95b209a0441194fb3578d0f774389)
@@ -5,5 +5,4 @@
 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
Index: schedsim/shell/schedsim_smpsimple/Makefile.am
===================================================================
--- schedsim/shell/schedsim_smpsimple/Makefile.am	(revision 4350081f85da91dd70cedde7f1fc086842b445f8)
+++ schedsim/shell/schedsim_smpsimple/Makefile.am	(revision cc1a54a7c8b95b209a0441194fb3578d0f774389)
@@ -5,5 +5,4 @@
 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
Index: schedsim/shell/schedsim_smpsimple/add_commands.c
===================================================================
--- schedsim/shell/schedsim_smpsimple/add_commands.c	(revision 4350081f85da91dd70cedde7f1fc086842b445f8)
+++ schedsim/shell/schedsim_smpsimple/add_commands.c	(revision cc1a54a7c8b95b209a0441194fb3578d0f774389)
@@ -19,5 +19,4 @@
 
 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);
@@ -32,12 +31,4 @@
     "no args",
     main_dump_ready_tasks
-  );
-  assert( cmd );
-
-  cmd = rtems_shell_add_cmd(
-    "cpus",
-    "rtems",
-    "no args",
-    main_dump_all_cpus
   );
   assert( cmd );
Index: schedsim/shell/shared/Makefile.am
===================================================================
--- schedsim/shell/shared/Makefile.am	(revision 4350081f85da91dd70cedde7f1fc086842b445f8)
+++ schedsim/shell/shared/Makefile.am	(revision cc1a54a7c8b95b209a0441194fb3578d0f774389)
@@ -29,4 +29,5 @@
 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
Index: schedsim/shell/shared/commands.c
===================================================================
--- schedsim/shell/shared/commands.c	(revision 4350081f85da91dd70cedde7f1fc086842b445f8)
+++ schedsim/shell/shared/commands.c	(revision cc1a54a7c8b95b209a0441194fb3578d0f774389)
@@ -31,5 +31,4 @@
 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;
@@ -40,4 +39,5 @@
 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[] = {
@@ -71,4 +71,5 @@
   &rtems_shell_TASK_EXECUTING_Command,
   &rtems_shell_TASK_HEIR_Command,
+  &rtems_shell_CPUS_Command,
   NULL
 };
Index: schedsim/shell/shared/main_dump_all_cpus.c
===================================================================
--- schedsim/shell/shared/main_dump_all_cpus.c	(revision 4350081f85da91dd70cedde7f1fc086842b445f8)
+++ schedsim/shell/shared/main_dump_all_cpus.c	(revision cc1a54a7c8b95b209a0441194fb3578d0f774389)
@@ -16,6 +16,6 @@
 #include "shell.h"
 #include "rtems_sched.h"
+#include "schedsim_shell.h"
 
-// #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
 #include <rtems.h>
 #include <rtems/score/percpu.h>
@@ -29,4 +29,6 @@
   Thread_Control *i;
   Thread_Control *e;
+  rtems_id        id;
+  bool            mismatch;
 
   printf(
@@ -34,5 +36,5 @@
     "          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;
@@ -48,4 +50,47 @@
   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 */
+};
Index: schedsim/shell/shared/main_taskcreate.c
===================================================================
--- schedsim/shell/shared/main_taskcreate.c	(revision 4350081f85da91dd70cedde7f1fc086842b445f8)
+++ schedsim/shell/shared/main_taskcreate.c	(revision cc1a54a7c8b95b209a0441194fb3578d0f774389)
@@ -14,6 +14,8 @@
 #endif
 
+#if defined(RTEMS_SMP)
 #define _GNU_SOURCE
 #include <sys/cpuset.h>
+#endif
 
 #include <stdio.h>
@@ -63,6 +65,8 @@
   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();
@@ -70,9 +74,9 @@
   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) ) {
@@ -84,4 +88,7 @@
 	CPU_ZERO( &cpuset );
 	cpuset.__bits[0] = affinity;
+#else
+        printf( "Ignoring affinity request on uniprocessor\n" );
+#endif
         break;
 
@@ -103,5 +110,5 @@
         break;
       default:
-        fprintf( stderr, "%s: Usage [-tTpP]\n", argv[0] );
+        fprintf( stderr, "%s: Usage [-a:tTpP]\n", argv[0] );
         return -1;
     }
@@ -155,4 +162,5 @@
   );
 
+#if defined(RTEMS_SMP)
   /*
    * If specified, set the affinity
@@ -174,4 +182,5 @@
     printf("Task (0x%08x) Set affinity=0x%08x\n", id, cpuset.__bits[0] );
   }
+#endif
 
   /*
