top (software)

From Wikipedia, the free encyclopedia
(Redirected from Top (Unix))
top
Original author(s)William LeFebvre
Initial release1984; 40 years ago (1984)
Written inC
Operating systemUnix-like
TypeProcess viewer / System monitor

top (table of processes) is a task manager or system monitor program, found in many Unix-like operating systems, that displays information about CPU and memory utilization.

Overview[edit]

The program produces an ordered list of running processes selected by user-specified criteria, and updates it periodically. Default ordering is by CPU usage, and only the top CPU consumers are shown. top shows how much processing power and memory are being used, as well as other information about the running processes. Some versions of top allow extensive customization of the display, such as choice of columns or sorting method. top is useful for system administrators, as it shows which users and processes are consuming the most system resources at any given time.

Top on Linux with altered preferences for better view

Implementations[edit]

There are several different versions of top. The traditional Unix version was written by William LeFebvre and originally copyrighted in 1984.[1] It is hosted on SourceForge,[2] and release 3.7 was announced in 2008.[3]

The Linux version of top is part of the procps-ng group of tools. It was originally written by Roger Binns[4] and released in early 1992 but shortly thereafter taken over by others.[5]

On Solaris, the roughly equivalent program is prstat. Microsoft Windows has the tasklist command and the graphical Task Manager utility. IBM AIX has an updating running processes list as part of the topas and topas_nmon commands.

The load average numbers in Linux refers to the sum of the number of processes waiting in the run-queue plus the number currently executing. The number is absolute, not relative. And thus it can be unbounded; unlike utilization. The instant variations of the number of processes are damped with an exponential decay formula which is calculated using fixed point math.[6]

The ps program is similar to top, but instead produces a snapshot of processes taken at the time of invocation. top's n (number of iterations) option can product a similar result, causing the program to run the specified number of iterations, then exit after printing its output.

Example[edit]

The first 5 rows overview the entire system.

top - 14:21:23 up 2 days, 21:40, 44 users,  load average: 14.44, 14.13, 14.64
        |                   |    |                         |
      <time>    <system uptime> <user count>         <load average for the past 1, 5, 15 minutes>

Tasks: 1552 total,   8 running, 1544 sleeping,   0 stopped,   0 zombie

%Cpu(s):  9.6 us,  0.7 sy,  0.0 ni, 89.5 id,  0.0 wa,  0.0 hi,  0.2 si,  0.0 st
              |        |        |        |        |        |        |         '------.
           <user>  <system>  <nice>  <idle> <IOWait> <hardware/software interrupt> <steal time>

MiB Mem : 1031911.+total, 368915.2 free, 172285.0 used, 490711.5 buff/cache
MiB Swap:   2048.0 total,   2048.0 free,      0.0 used. 807110.1 avail Mem

load average is the exponential moving average of the run-queue length over the past 1/5/15 minutes. The run-queue includes both processes being run and waiting to be run. At complete utilization with no task switching, the load average is equal to the number of CPUs.[7]

Tasks counts the processes their statuses.

%Cpu(s) counts the percentage of CPU usage, broken down into categories.

MiB Mem: Memory usage in units of mebibyte. The buff/cache is for memory used by buffers and cache.

MiB Swap: Swap space usage in units of mebibyte. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. In this snapshot, there's a total of 2048 MiB of swap, all free, indicating that no swapping is occurring, which is good for performance.

avail Mem: The amount of memory available for new applications, without swapping. This considers not just the unused RAM, but also the memory that can be reclaimed from RAM caches.

The rest of the text provides a table with each row being a process, with the following columns often used out of many possible columns (the choice and ordering of columns are configurable):[8]

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
      1 root      20   0    2456   1612   1500 S   0.0   0.0   0:00.07 init(Ubuntu)
      4 root      20   0    2456      4      0 S   0.0   0.0   0:00.00 init
 656403 user2     20   0   80.0g   3.6g 370000 S 100.0   0.4   1594:38 python3
2024198 longnam+  20   0   50.5g   4.7g 609200 S   1.6   0.5 204:46.85 long-name-proc
2056804 longnam+  20   0  237.1g  31.1g  23.1g S 136.8   3.1  69:54.11 python3
  • PID: Process ID, a unique number identifying each running process.
  • USER: The user who started the process. If the username is too long, it is cut-off with a + at the end.
  • PR: Real-time priority of the task, computed by the system scheduler. Lower PR numbers are considered more important by the scheduler and more likely to be scheduled, which means it tends to have more CPU-time per real-time.
  • NI: The niceness of the task, manually set by users and administrators to influence the real-time priority. A lower nice value tends to favor the process, and a higher nice value tends to disfavor the process. It ranges from -20 (most favored) to 19 (least favored).
  • VIRT: Virtual memory size of the process. This includes all memory that the process can access, including memory that is swapped out, memory that is allocated but not used, and shared memory.
  • RES: Resident set size, the portion of a process's memory that is held in RAM. Compared with VIRT, this excludes memory that is swapped out, not yet used, or shared.
  • SHR: Shared memory size: how much of the RAM claimed by the process is sharable with other processes.
  • S: Status of process. The status can be:
    • D = uninterruptible sleep, I = idle R = running S = sleeping T = stopped by job control signal t = stopped by debugger during trace Z = zombie
    • R for running
    • S for sleeping
    • I for idle
    • D for disk sleep (uninterruptible)
    • Z for zombie (terminated but not reaped by its parent)
    • T for stopped by a job control signal or t for stopped by debugger during tracing.
  • %CPU: The percentage of the CPU time that the process is currently using.
  • %MEM: The percentage of the physical RAM used by the process.
  • TIME+: The total CPU time the task has used since it started. This is shown in minutes:seconds . The plus sign in TIME+ means that it is accurate to 0.01 second. If it shows TIME then it is accurate to 1 second.
  • COMMAND: The command line argument that started the process. Unlike USER , if the command is too long, it is cut-off without a + at the end.

See also[edit]

References[edit]

  1. ^ "Documentation". Unix Top. Archived from the original on 2008-04-13. Retrieved 2016-05-22.
  2. ^ LeFebvre, William (2014-09-16). "About Top". Unix Top. Archived from the original on 2004-04-20. Retrieved 2016-05-22.
  3. ^ "Top / News". SourceForge. Retrieved 2016-05-22.
  4. ^ "top(1): tasks - Linux man page". Linux Documentation. Retrieved 2016-05-22.
  5. ^ Binns, Roger. "Linux Top Origins | Roger's world". Roger's world. Retrieved 2016-05-22.
  6. ^ J. Gunther, Neil (2010). "UNIX Load Average Part 2: Not Your Average Average" (PDF). teamquest.com. Archived from the original (PDF) on 2012-06-02. Retrieved 2013-06-10.
  7. ^ Walker, Ray (1 December 2006). "Examining Load Average". Linux Journal. Retrieved 13 March 2012.
  8. ^ top(1) - Linux man page

External links[edit]