Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:19

0001 /*
0002  *  CPUUSE Command Implementation
0003  *
0004  *  COPYRIGHT (c) 1989-2008.
0005  *  On-Line Applications Research Corporation (OAR).
0006  *
0007  *  The license and distribution terms for this file may be
0008  *  found in the file LICENSE in this distribution or at
0009  *  http://www.rtems.org/license/LICENSE.
0010  */
0011 
0012 #ifdef HAVE_CONFIG_H
0013 #include "config.h"
0014 #endif
0015 
0016 #include <stdio.h>
0017 #include <string.h>
0018 
0019 #include <rtems.h>
0020 #include <rtems/cpuuse.h>
0021 #include <rtems/printer.h>
0022 #include <rtems/shell.h>
0023 #include "internal.h"
0024 
0025 static int rtems_shell_main_cpuuse(
0026   int   argc,
0027   char *argv[]
0028 )
0029 {
0030   /*
0031    *  When invoked with no arguments, print the report.
0032    */
0033   if ( argc == 1 ) {
0034     rtems_printer printer;
0035     rtems_print_printer_fprintf(&printer, stdout);
0036     rtems_cpu_usage_report_with_plugin(&printer);
0037     return 0;
0038   }
0039 
0040   /*
0041    *  When invoked with the single argument -r, reset the statistics.
0042    */
0043   if ( argc == 2 && !strcmp( argv[1], "-r" ) ) {
0044     printf( "Resetting CPU Usage information\n" );
0045     rtems_cpu_usage_reset();
0046     return 0;
0047   }
0048 
0049   /*
0050    *  OK.  The user did something wrong.
0051    */
0052   fprintf( stderr, "%s: [-r]\n", argv[0] );
0053   return -1;
0054 }
0055 
0056 rtems_shell_cmd_t rtems_shell_CPUUSE_Command = {
0057   "cpuuse",                                   /* name */
0058   "[-r] print or reset per thread cpu usage", /* usage */
0059   "rtems",                                    /* topic */
0060   rtems_shell_main_cpuuse,                    /* command */
0061   NULL,                                       /* alias */
0062   NULL                                        /* next */
0063 };