JorgeGzm opened a new pull request, #3628:
URL: https://github.com/apache/nuttx-apps/pull/3628

   ## Summary
   
   Improve the output and usability of the built-in `top` command:
   
   - Print a Linux-top-like summary header before the task list: uptime,
     task counts (total/running/sleeping), CPU busy/idle and memory usage.
     All values are gathered via `sysinfo()`, no extra procfs parsing.
   - Refresh the screen in place (cursor home + erase-line per row +
     erase-below) instead of clearing the whole screen on every cycle,
     which removes the flicker.
   - Poll stdin during the update interval and exit on `q`, `ESC` or
     `Ctrl-C`. Previously the only exit path was the SIGINT handler,
     which requires both `CONFIG_ENABLE_ALL_SIGNALS` (the handler) and
     `CONFIG_TTY_SIGINT` (the serial console converts Ctrl-C into
     SIGINT — default `n`); on configurations missing either option
     `top` could not be terminated at all.
   - Move the ANSI escape sequences to named defines and print the task
     list title in bold.
   
   The per-task table, sorting by CPU load and the existing options
   (`-n`, `-d`, `-p`, `-h`) are unchanged.
   
   Companion PR (documentation + board example): apache/nuttx#XXXXX
   
   ## Impact
   
   - **User**: nicer and more informative `top` output; the command can
     now always be exited from the keyboard, regardless of signal
     configuration.
   - **Build**: none. Same dependencies as before (`NSH_HAVE_CPULOAD`);
     only adds `poll.h` and `sysinfo()`, available on all configurations
     that already build `cmd_top`.
   - **Hardware**: none, generic code.
   - **Documentation**: covered by the companion nuttx PR, which adds the
     previously missing `top` section to the NSH commands page.
   - **Compatibility**: output format changes (summary header added, bold
     title). Option semantics are unchanged.
   
   ## Testing
   
   - Build host: Linux x86_64, GCC arm-none-eabi
   - Target: linum-stm32h753bi:nsh (STM32H753BI) — tested on hardware
   - `tools/checkpatch.sh -g HEAD~1..HEAD`: all checks pass
   
   Before (flicker on every refresh; no summary; cannot exit without
   CONFIG_ENABLE_ALL_SIGNALS):
   
   ```
       TID   PID  PPID PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK      
      STACK    USED FILLED    CPU COMMAND
         0     0     0   0 FIFO     Kthread   - Ready              
0000000000000000 0002024 0000500  24.7%  91.8% Idle_Task
         2     2     0 100 RR       Task      - Running            
0000000000000000 0004048 0001952  48.2%   8.1% nsh_main
     use Ctrl+c' to quit
   ```
   
   After (in-place refresh, exits with q/ESC/Ctrl-C):
   
   ```
     nsh> top
     top - up 00:00:19
     Tasks: 2 total, 2 running, 0 sleeping
     %Cpu(s):  8.1 busy, 91.9 idle
     Mem :  1004876 total,     8140 used,   996736 free
   
       TID   PID  PPID PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK      
      STACK    USED FILLED    CPU COMMAND
         0     0     0   0 FIFO     Kthread   - Ready              
0000000000000000 0002024 0000500  24.7%  91.8% Idle_Task
         2     2     0 100 RR       Task      - Running            
0000000000000000 0004048 0001952  48.2%   8.1% nsh_main


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to