Linux – Les états des processus

From Tuxunix
Jump to: navigation, search

Linux – Les différents états des processus

Plusieurs états sont possibles:

  • D : En sommeil ininterruptible (À un processus résident quelque part dans le système qui n’arrive pas à effectuer une tâche ou une autre. Typiquement un tar sur un dérouleur de bande qui foire. Au passage, c’est un truc bien sympathique parce que ça bloque à la fois le processus mais aussi le périphérique. Le processus est typiquement en train d’effectuer une tâche non interruptible qui ne peut pas se faire en raison d’une erreur ou d’une autre)
  • R : En cours d’exécution (le process est actif et consomme des ressources, en user mode ou kernel mode)
  • S : En sommeil (le process n’est pas actif mais susceptible d’être réveillé par un appel système
  • T : Stoppé ou stracé (Le processus a reçu un signal d’arrêt temporaire et attend un SIGCONT)
  • Z : Zombie (l’état ‘Z’ correspond à un fils dont le père n’est pas encore allé à l’enterrement. En d’autres termes, la valeur de retour du processus n’a pas été lu par le père (ou par init dans le cas où le père n’existe plus). Ce processus ne consomme plus que la place de la structure de description du processus à l’exclusion de toute autre ressource)


Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process.

  • D Uninterruptible sleep (usually IO)
  • R Running or runnable (on run queue)
  • S Interruptible sleep (waiting for an event to complete)
  • T Stopped, either by a job control signal or because it is being traced.
  • W paging (not valid since the 2.6.xx kernel)
  • X dead (should never be seen)
  • Z Defunct ("zombie") process, terminated but not reaped by its parent.

For BSD formats and when the stat keyword is used, additional characters may be displayed: < high-priority (not nice to other users)

  • N low-priority (nice to other users)
  • L has pages locked into memory (for real-time and custom IO)
  • s is a session leader
  • l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
  • + is in the foreground process group


TOP

Example 2-1 Example output from the top command
top - 02:06:59 up 4 days, 17:14, 2 users, load average: 0.00, 0.00, 0.00
Tasks: 62 total, 1 running, 61 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.2% us, 0.3% sy, 0.0% ni, 97.8% id, 1.7% wa, 0.0% hi, 0.0% si
Mem: 515144k total, 317624k used, 197520k free, 66068k buffers
Swap: 1048120k total, 12k used, 1048108k free, 179632k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
13737 root 17 0 1760 896 1540 R 0.7 0.2 0:00.05 top
238 root 5 -10 0 0 0 S 0.3 0.0 0:01.56 reiserfs/0
1 root 16 0 588 240 444 S 0.0 0.0 0:05.70 init
2 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
3 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0
4 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/1
5 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/1
6 root 5 -10 0 0 0 S 0.0 0.0 0:00.02 events/0
7 root 5 -10 0 0 0 S 0.0 0.0 0:00.00 events/1
8 root 5 -10 0 0 0 S 0.0 0.0 0:00.09 kblockd/0
9 root 5 -10 0 0 0 S 0.0 0.0 0:00.01 kblockd/1
10 root 15 0 0 0 0 S 0.0 0.0 0:00.00 kirqd
13 root 5 -10 0 0 0 S 0.0 0.0 0:00.02 khelper/0
14 root 16 0 0 0 0 S 0.0 0.0 0:00.45 pdflush
16 root 15 0 0 0 0 S 0.0 0.0 0:00.61 kswapd0
17 root 13 -10 0 0 0 S 0.0 0.0 0:00.00 aio/0
18 root 13 -10 0 0 0 S 0.0 0.0 0:00.00 aio/1

You can further modify the processes using renice to give a new priority to each process. If a process hangs or occupies too much CPU, you can kill the process (kill command). The columns in the output are:

  • PID Process identification.
  • USER Name of the user who owns (and perhaps started) the process.
  • PRI Priority of the process. (See 1.1.4, “Process priority and nice level” on page 5 for details.)
netperf Network performance benchmark Tool Most useful tool function42 Linux Performance and Tuning Guidelines
  • NI Niceness level (Whether the process tries to be nice by adjusting the priority
by the number given. See below for details.)
  • SIZE Amount of memory (code+data+stack) used by the process in kilobytes.
  • RSS Amount of physical RAM used, in kilobytes.
  • SHARE Amount of memory shared with other processes, in kilobytes.
  • STAT State of the process: S=sleeping, R=running, T=stopped or traced, D=interruptible sleep, Z=zombie. The process state is discussed in 1.1.7, “Process state” on page 6.
  • %CPU Share of the CPU usage (since the last screen update).
  • %MEM v Share of physical memory.
  • TIME Total CPU time used by the process (since it was started).
  • COMMAND Command line used to start the task (including parameters).
The top utility supports several useful hot keys, including:
  • t Displays summary information off and on.
  • m Displays memory information off and on.
  • A Sorts the display by top consumers of various system resources. Useful for
quick identification of performance-hungry tasks on a system.
  • f Enters an interactive configuration screen for top. Helpful for setting up top
for a specific task.
  • o Enables you to interactively select the ordering within top.
  • r Issues renice command.
  • k Issues kill command.