source: rtems-schedsim/schedsim/shell/shared/main_dump_all_cpus.c @ cc1a54a

Last change on this file since cc1a54a was cc1a54a, checked in by Joel Sherrill <joel.sherrill@…>, on 05/22/14 at 15:19:55

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.

  • Property mode set to 100644
File size: 2.4 KB
RevLine 
[f40778b]1/*
[a2aad55]2 *  COPYRIGHT (c) 1989-2013.
[f40778b]3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#include <newlib/getopt.h>
11#include <stdio.h>
12#include <stdlib.h>
13#include <string.h>
14#include <ctype.h>
15
16#include "shell.h"
17#include "rtems_sched.h"
[cc1a54a]18#include "schedsim_shell.h"
[f40778b]19
20#include <rtems.h>
21#include <rtems/score/percpu.h>
22#include <rtems/score/smp.h>
23#include <rtems/score/schedulerpriority.h>
24
25int main_dump_all_cpus(int argc, char **argv)
26{
27  uint32_t        cpu;
28  Thread_Control *h;
29  Thread_Control *i;
30  Thread_Control *e;
[cc1a54a]31  rtems_id        id;
32  bool            mismatch;
[f40778b]33
34  printf(
35    "=== CPU Status\n"
[49fbe09]36    "          EXECUTING      /   HEIR             / SWITCH NEEDED\n"
[f40778b]37  );
[cc1a54a]38  for ( cpu=0 ; cpu < rtems_get_processor_count() ; cpu++ ) {
[726b27c]39    e = _Per_CPU_Information[cpu].per_cpu.executing;
40    h = _Per_CPU_Information[cpu].per_cpu.heir;
[f40778b]41    printf(
[726b27c]42      "  CPU %d: 0x%08x @%3ld / 0x%08x @%3ld          %s\n",
[f40778b]43      cpu,
44      e->Object.id, (long) e->current_priority,
45      h->Object.id, (long) h->current_priority,
[726b27c]46      ((_Per_CPU_Information[cpu].per_cpu.dispatch_necessary) ?
47         "true" : "false")
[f40778b]48    );
49  }
50  printf( "=== End of Ready Set of Threads\n" );
[b38dbcc]51
[cc1a54a]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
[f40778b]86  return 0;
87}
[cc1a54a]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};
Note: See TracBrowser for help on using the repository browser.