source: rtems/cpukit/libmisc/shell/main_cpuuse.c @ a3ddb08b

4.104.114.95
Last change on this file since a3ddb08b was a3ddb08b, checked in by Joel Sherrill <joel.sherrill@…>, on 03/05/08 at 02:49:35

2008-03-04 Joel Sherrill <joel.sherrill@…>

  • libmisc/Makefile.am, libmisc/shell/main_cp.c, libmisc/shell/main_cpuuse.c, libmisc/shell/main_date.c, libmisc/shell/main_mallocinfo.c, libmisc/shell/main_netstats.c, libmisc/shell/main_perioduse.c, libmisc/shell/main_stackuse.c, libmisc/shell/main_wkspaceinfo.c, libmisc/shell/print_heapinfo.c, libmisc/shell/shell.c, libmisc/shell/shell.h, libmisc/shell/shell_makeargs.c, libmisc/shell/shellconfig.c, libmisc/shell/shellconfig.h, libmisc/shell/write_file.c: Add initial capability to automatically execute a script from the filesystem. Add echo command from NetBSD and sleep command.
  • libmisc/shell/main_echo.c, libmisc/shell/main_sleep.c, libmisc/shell/shell_script.c: New files.
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 *  CPUUSE Command Implementation
3 *
4 *  COPYRIGHT (c) 1989-2008.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <stdio.h>
19
20#include <rtems.h>
21#include <rtems/cpuuse.h>
22#include <rtems/shell.h>
23#include "internal.h"
24
25int rtems_shell_main_cpuuse(
26  int   argc,
27  char *argv[]
28)
29{
30  /*
31   *  When invoked with no arguments, print the report.
32   */
33  if ( argc == 1 ) {
34    rtems_cpu_usage_report_with_plugin(stdout, (rtems_printk_plugin_t)fprintf);
35    return 0;
36  }
37
38  /*
39   *  When invoked with the single argument -r, reset the statistics.
40   */
41  if ( argc == 2 && !strcmp( argv[1], "-r" ) ) {
42    printf( "Resetting CPU Usage information\n" );
43    rtems_cpu_usage_reset();
44    return 0;
45  }
46
47  /*
48   *  OK.  The user did something wrong.
49   */
50  fprintf( stderr, "%s: [-r]\n", argv[0] );
51  return -1;
52}
53
54rtems_shell_cmd_t rtems_shell_CPUUSE_Command = {
55  "cpuuse",                                   /* name */
56  "[-r] print or reset per thread cpu usage", /* usage */
57  "rtems",                                    /* topic */
58  rtems_shell_main_cpuuse,                    /* command */
59  NULL,                                       /* alias */
60  NULL                                        /* next */
61};
Note: See TracBrowser for help on using the repository browser.