Changeset cc1a54a in rtems-schedsim


Ignore:
Timestamp:
May 22, 2014, 3:19:55 PM (5 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
master
Children:
be883c2
Parents:
4350081
git-author:
Joel Sherrill <joel.sherrill@…> (05/22/14 15:19:55)
git-committer:
Joel Sherrill <joel.sherrill@…> (05/22/14 15:21:44)
Message:

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.

Location:
schedsim
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • schedsim/UsingTheSchedulerSimulator.txt

    r4350081 rcc1a54a  
    99Joel Sherrill <joel.sherrill@oarcorp.com>
    1010
    11 1.0, 5 May 2013
     111.1, 22 May 2014
    1212
    1313Introduction
     
    163163task_create Command
    164164^^^^^^^^^^^^^^^^^^^
    165 *Usage*: task_create name priority
     165*Usage*: task_create [-tT] [-pP] [-a affinity] name priority
    166166
    167167This command creates and starts a Classic API task with the specified name
    168168and initial priority. It also starts the task.  This is the equivalent
    169169of the rtems_task_create and rtems_task_start Classic API directives.
     170
     171In SMP configurations, the -a argument can be used to specify the
     172affinity of the created task if the default affinity is not desired.
     173In this case, rtems_task_set_affinity is invoked between the calls
     174to rtems_task_create and rtems_task_start Classic API directives.
     175
     176The command line arguments are processed as follows:
     177
     178* -t - disable timeslicing
     179* -T - enable timeslicing
     180* -p - disable preemption
     181* -p - enable preemption
     182* -a affinity - specify affinity mask
     183
    170184The following is the output from the invocation 'task_create joel 5':
    171185
     
    249263for the specified number of ticks.  It is the equivalent of the
    250264rtems_task_wake_after directive in the Classic API.
     265
     266task_get_affinity Command
     267^^^^^^^^^^^^^^^^^^^^^^^^^
     268*Usage*: task_get_affinity task
     269
     270This command is used to print the affinity of the specified task.
     271It is the equivalent of the rtems_task_get_affinity directive
     272in the Classic API.
     273
     274task_set_affinity Command
     275^^^^^^^^^^^^^^^^^^^^^^^^^
     276*Usage*: task_set_affinity task affinity
     277
     278This command is used to modify the affinity of the specified task.
     279It is the equivalent of the rtems_task_set_affinity directive
     280in the Classic API.
    251281
    252282clock_tick Command
     
    308338in the Classic API.
    309339
     340
     341cpus Command
     342^^^^^^^^^^^^
     343*Usage*: cpus [expected0 .. expectedn]
     344
     345This method prints the executing and heir thread for each processor
     346in the system. If provided with arguments, the argumnents may be
     347task names or ids and indicate the task which is expected to be
     348executing on that processor. If the expected task name/id is '-',
     349then that processor is not checked.
     350
     351In the event that the executing thread does not match the expected,
     352the scenario is aborted. This allows for self-checking scenarios.
    310353
    311354executing Command
  • schedsim/rtems/Makefile.am

    r4350081 rcc1a54a  
    176176librtems_a_SOURCES += $(cpukitdir)/rtems/src/clocktodtoseconds.c
    177177librtems_a_SOURCES += $(cpukitdir)/rtems/src/clocktodvalidate.c
     178librtems_a_SOURCES += $(cpukitdir)/rtems/src/getprocessorcount.c
    178179librtems_a_SOURCES += $(cpukitdir)/rtems/src/sem.c
    179180librtems_a_SOURCES += $(cpukitdir)/rtems/src/semcreate.c
  • schedsim/shell/schedsim_smppriority/Makefile.am

    r4350081 rcc1a54a  
    55SOURCES += $(srcdir)/../schedsim_smpsimple/main_current_cpu.c
    66SOURCES += $(srcdir)/../schedsim_smpsimple/main_dispatch.c
    7 SOURCES += $(srcdir)/../schedsim_smpsimple/main_dump_all_cpus.c
    87SOURCES += $(srcdir)/../schedsim_smpsimple/main_dump_ready_tasks.c
    98SOURCES += $(srcdir)/../schedsim_smpsimple/printheir_executing.c
  • schedsim/shell/schedsim_smppriority_affinity/Makefile.am

    r4350081 rcc1a54a  
    55SOURCES += $(srcdir)/../schedsim_smpsimple/main_current_cpu.c
    66SOURCES += $(srcdir)/../schedsim_smpsimple/main_dispatch.c
    7 SOURCES += $(srcdir)/../schedsim_smpsimple/main_dump_all_cpus.c
    87SOURCES += $(srcdir)/../schedsim_smpsimple/main_dump_ready_tasks.c
    98SOURCES += $(srcdir)/../schedsim_smpsimple/printheir_executing.c
  • schedsim/shell/schedsim_smpsimple/Makefile.am

    r4350081 rcc1a54a  
    55schedsim_smpsimple_SOURCES += main_current_cpu.c
    66schedsim_smpsimple_SOURCES += main_dispatch.c
    7 schedsim_smpsimple_SOURCES += main_dump_all_cpus.c
    87schedsim_smpsimple_SOURCES += main_dump_ready_tasks.c
    98schedsim_smpsimple_SOURCES += printheir_executing.c
  • schedsim/shell/schedsim_smpsimple/add_commands.c

    r4350081 rcc1a54a  
    1919
    2020extern int main_dump_ready_tasks(int argc, char **argv);
    21 extern int main_dump_all_cpus(int argc, char **argv);
    2221extern int main_set_current_cpu(int argc, char **argv);
    2322extern int main_dispatch(int argc, char **argv);
     
    3231    "no args",
    3332    main_dump_ready_tasks
    34   );
    35   assert( cmd );
    36 
    37   cmd = rtems_shell_add_cmd(
    38     "cpus",
    39     "rtems",
    40     "no args",
    41     main_dump_all_cpus
    4233  );
    4334  assert( cmd );
  • schedsim/shell/shared/Makefile.am

    r4350081 rcc1a54a  
    2929libschedsim_a_SOURCES += lookup_semaphore.c
    3030libschedsim_a_SOURCES += lookup_task.c
     31libschedsim_a_SOURCES += main_dump_all_cpus.c
    3132libschedsim_a_SOURCES += main_echo.c
    3233libschedsim_a_SOURCES += main_executing.c
  • schedsim/shell/shared/commands.c

    r4350081 rcc1a54a  
    3131extern rtems_shell_cmd_t rtems_shell_CLOCK_TICK_Command;
    3232
    33 
    3433extern rtems_shell_cmd_t rtems_shell_SEMAPHORE_CREATE_Command;
    3534extern rtems_shell_cmd_t rtems_shell_SEMAPHORE_DELETE_Command;
     
    4039extern rtems_shell_cmd_t rtems_shell_TASK_EXECUTING_Command;
    4140extern rtems_shell_cmd_t rtems_shell_TASK_HEIR_Command;
     41extern rtems_shell_cmd_t rtems_shell_CPUS_Command;
    4242
    4343rtems_shell_cmd_t *rtems_shell_Initial_commands[] = {
     
    7171  &rtems_shell_TASK_EXECUTING_Command,
    7272  &rtems_shell_TASK_HEIR_Command,
     73  &rtems_shell_CPUS_Command,
    7374  NULL
    7475};
  • schedsim/shell/shared/main_dump_all_cpus.c

    r4350081 rcc1a54a  
    1616#include "shell.h"
    1717#include "rtems_sched.h"
     18#include "schedsim_shell.h"
    1819
    19 // #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
    2020#include <rtems.h>
    2121#include <rtems/score/percpu.h>
     
    2929  Thread_Control *i;
    3030  Thread_Control *e;
     31  rtems_id        id;
     32  bool            mismatch;
    3133
    3234  printf(
     
    3436    "          EXECUTING      /   HEIR             / SWITCH NEEDED\n"
    3537  );
    36   for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) {
     38  for ( cpu=0 ; cpu < rtems_get_processor_count() ; cpu++ ) {
    3739    e = _Per_CPU_Information[cpu].per_cpu.executing;
    3840    h = _Per_CPU_Information[cpu].per_cpu.heir;
     
    4850  printf( "=== End of Ready Set of Threads\n" );
    4951
     52  /*
     53   * If no arguments, then we were not requested to verify task placement.
     54   */
     55  if ( argc == 1 )
     56    return 0;
     57
     58  /*
     59   * Now verify the thread on each processor.
     60   */
     61  mismatch = false;
     62  for ( cpu=0 ; cpu < rtems_get_processor_count() ; cpu++ ) {
     63    e = _Per_CPU_Information[cpu].per_cpu.executing;
     64
     65    if ( argv[cpu + 1][ 0 ] == '-' )
     66      continue;
     67
     68    if ( lookup_task( argv[cpu + 1], &id ) )
     69      return -1;
     70
     71    if ( e->Object.id != id ) {
     72      mismatch = true;
     73      printf(
     74        "*** ERROR on CPU %d Expected 0x%08x found 0x%08x executing\n",
     75        cpu,
     76        id,
     77        e->Object.id
     78      );
     79    }
     80  }
     81  if ( mismatch ) {
     82    printf( "Exiting test scenario due to scheduling failure\n" );
     83    exit( 1 );
     84  }
     85
    5086  return 0;
    5187}
     88
     89rtems_shell_cmd_t rtems_shell_CPUS_Command = {
     90  "cpus",                           /* name */
     91  "cpus [tasks expected on cores]", /* usage */
     92  "rtems",                          /* topic */
     93  main_dump_all_cpus,              /* command */
     94  NULL,                             /* alias */
     95  NULL                              /* next */
     96};
  • schedsim/shell/shared/main_taskcreate.c

    r4350081 rcc1a54a  
    1414#endif
    1515
     16#if defined(RTEMS_SMP)
    1617#define _GNU_SOURCE
    1718#include <sys/cpuset.h>
     19#endif
    1820
    1921#include <stdio.h>
     
    6365  int                arg;
    6466  unsigned long      affinity;
     67#if defined(RTEMS_SMP)
    6568  cpu_set_t          cpuset;
    66   bool               do_affinity;
     69  bool               do_affinity = false;
     70#endif
    6771
    6872  CHECK_RTEMS_IS_UP();
     
    7074  mode = 0;
    7175  mask = 0;
    72   do_affinity = false;
    7376  memset(&getopt_reent, 0, sizeof(getopt_data));
    7477  while ( (option = getopt_r( argc, argv, "a:tTpP", &getopt_reent)) != -1 ) {
    7578    switch (option) {
    7679      case 'a':
     80#if defined(RTEMS_SMP)
    7781        c_p = getopt_reent.optarg;
    7882        if ( rtems_string_to_unsigned_long( c_p, &affinity, NULL, 0) ) {
     
    8488        CPU_ZERO( &cpuset );
    8589        cpuset.__bits[0] = affinity;
     90#else
     91        printf( "Ignoring affinity request on uniprocessor\n" );
     92#endif
    8693        break;
    8794
     
    103110        break;
    104111      default:
    105         fprintf( stderr, "%s: Usage [-tTpP]\n", argv[0] );
     112        fprintf( stderr, "%s: Usage [-a:tTpP]\n", argv[0] );
    106113        return -1;
    107114    }
     
    155162  );
    156163
     164#if defined(RTEMS_SMP)
    157165  /*
    158166   * If specified, set the affinity
     
    174182    printf("Task (0x%08x) Set affinity=0x%08x\n", id, cpuset.__bits[0] );
    175183  }
     184#endif
    176185
    177186  /*
Note: See TracChangeset for help on using the changeset viewer.