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

Last change on this file since 9372906 was 9372906, checked in by Joel Sherrill <joel.sherrill@…>, on 05/22/14 at 21:17:48

main_dump_all_cpus.c: Stop at end of args or CPUs

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2013.
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"
18#include "schedsim_shell.h"
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;
31  rtems_id        id;
32  bool            mismatch;
33
34  printf(
35    "=== CPU Status\n"
36    "          EXECUTING      /   HEIR             / SWITCH NEEDED\n"
37  );
38  for ( cpu=0 ; cpu < rtems_get_processor_count() ; cpu++ ) {
39    e = _Per_CPU_Information[cpu].per_cpu.executing;
40    h = _Per_CPU_Information[cpu].per_cpu.heir;
41    printf(
42      "  CPU %d: 0x%08x @%3ld / 0x%08x @%3ld          %s\n",
43      cpu,
44      e->Object.id, (long) e->current_priority,
45      h->Object.id, (long) h->current_priority,
46      ((_Per_CPU_Information[cpu].per_cpu.dispatch_necessary) ?
47         "true" : "false")
48    );
49  }
50  printf( "=== End of Ready Set of Threads\n" );
51
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 < argc ; 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 ( !strcmp( argv[cpu + 1], "IDLE" )) {
72      /* XXX should do something cleaner for the ID mask */
73      if ( (e->Object.id & 0xFFFF0000) != 0x09010000 ) {
74        mismatch = true;
75        printf(
76          "*** ERROR on CPU %d Expected an IDLE found 0x%08x executing\n",
77          cpu,
78          e->Object.id
79        );
80      }
81    } else {
82      if ( lookup_task( argv[cpu + 1], &id ) ) {
83        printf(
84          "*** ERROR in scenario -- unknown task %s\n",
85           argv[cpu + 1]
86        );
87        exit( 1 );
88      }
89
90      if ( e->Object.id != id ) {
91        mismatch = true;
92        printf(
93          "*** ERROR on CPU %d Expected 0x%08x found 0x%08x executing\n",
94          cpu,
95          id,
96          e->Object.id
97        );
98      }
99    }
100  }
101  if ( mismatch ) {
102    printf( "Exiting test scenario due to scheduling failure\n" );
103    exit( 1 );
104  }
105
106  return 0;
107}
108
109rtems_shell_cmd_t rtems_shell_CPUS_Command = {
110  "cpus",                           /* name */
111  "cpus [tasks expected on cores]", /* usage */
112  "rtems",                          /* topic */
113  main_dump_all_cpus,              /* command */
114  NULL,                             /* alias */
115  NULL                              /* next */
116};
Note: See TracBrowser for help on using the repository browser.