source: rtems-schedsim/schedsim/shell/shared/main_currentcpu.c @ e340e96

Last change on this file since e340e96 was e340e96, checked in by Joel Sherrill <joel.sherrill@…>, on May 26, 2014 at 5:46:20 PM

current_cpu is now a shared SMP command

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 *  @file
3 *  @brief current_cpu Command in Scheduler Simulator
4 */
5
6/*
7 *  COPYRIGHT (c) 1989-2014.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.com/license/LICENSE.
13 */
14
15#include <newlib/getopt.h>
16#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19#include <ctype.h>
20
21#include "shell.h"
22#include "rtems_sched.h"
23
24#include <rtems.h>
25#include <rtems/score/percpu.h>
26#include <rtems/score/schedulerpriority.h>
27#include <rtems/stringto.h>
28
29extern uint32_t Schedsim_Current_cpu;
30
31int rtems_shell_main_current_cpu(int argc, char **argv)
32{
33  long cpu;
34
35  if ( argc >= 2 ) {
36    if ( rtems_string_to_long(argv[1], &cpu, NULL, 0) ) {
37      printf( "CPU argument (%s) is not a number\n", argv[1] );
38      return -1;
39    }
40    printf(
41      "Changing current CPU from %d to %d\n",
42      Schedsim_Current_cpu,
43      cpu
44    );
45    Schedsim_Current_cpu = cpu;
46  } else {
47    printf( "Current CPU is %d\n", Schedsim_Current_cpu );
48  }
49
50  return 0;
51}
52
53rtems_shell_cmd_t rtems_shell_CURRENT_CPU_Command = {
54  "current_cpu",                 /* name */
55  "current_cpu [cpu]",           /* usage */
56  "rtems",                       /* topic */
57  rtems_shell_main_current_cpu,  /* command */
58  NULL,                          /* alias */
59  NULL                           /* next */
60};
Note: See TracBrowser for help on using the repository browser.