Linux process understanding

What is the process

Process running program

The so-called process, as long as it is regarded as a "running program". In addition, there are many cases where multiple processes are generated from one program.
In the case of Linux, if it is a desktop environment, there will be more than 100 processes. The status can be confirmed by the top command, etc.
Insert picture description here

Process management

If a large number of processes are started, of course computer resources will be consumed. Management "What is the number of processes in stable operation?" You should master it.
The OS will allocate appropriate computer resources, memory, and CPU time for the program. On the allocated resources, the program runs as a process on the operating system. The process basically ends when it works, and resources such as memory are opened. In the case of server-related processes, it is called a "daemon", basically as long as the user does not say "please end" under the program, it continues to run.

The name of the resident program in the UNIX operating system (Linux, Mac, etc.) is "daemon".

Zombie process

The process that completes the task but does not open the memory is called a "zombie process." When it becomes a zombie process, the user can issue the kill command and forcefully terminate the process.

Multitasking

As a premise, it can be considered as "task=process". It's just a different name. The structure of a system that can run multiple processes at the same time is called "multitasking".

A basic single-core CPU can only execute one command at a time. I asked: "Our computers are indeed dual-core. Can Word, Excel and browsers be used at the same time?" This question may arise. In fact, if it is dual, only two can be moved, but it is too inconvenient to do so.

The computer is switching the process of execution with a "momentum that cannot be captured by anyone."

Therefore, we have an illusion as if the processes are running at the same time. Multitasking is achieved through modern CPU technology.

Instructions

ps command

$ ps aux

Insert picture description here
The "aux" after ps links the three options "a", "u" and "x" to describe them.
By adding these options, the project will display all the processes running in the system, as described above.

  • USER: The name of the user who is running.
  • PID: The identification number assigned to the process, that is, the process ID.
  • %CPU: CPU usage rate.
  • %MEM: Memory usage rate.
  • VSZ: The virtual memory size guaranteed by the process.
  • RSS: The amount of memory actually used.
  • TTY: Terminal name.
  • STAT: Display process status.
  • START: The time when the command was started.
  • TIME: The total execution time of the process.
  • COMMAND: Command name The
    process status includes the following options.
  • S: Sleep or wait for user input.
  • D: The input and output of the disk are waiting.
  • R: Executable or executing.
  • T: The suspend signal is sent to the execution interrupt.
  • Z: Zombie state.
  • <: Increase the priority of the schedule.
  • N: The scheduling priority is lowered.
  • L: L memory pages are locked and used.
  • S: Conversation reader.
  • +: foreground process group

pts is a virtual terminal such as a terminal. In contrast, tty refers to the actual terminal. In the case of "?", it becomes a process without a terminal.
Processes such as daemons have no terminals.

There are a large number of options in ps, especially "ps aux" is often used. It should be noted that, unlike "ps-aux", when you habitually specify options, "-" If you want to use part of the options of ps, please like Same as "ps aux". You can use the ps man command (show command usage) to view

$ man ps

pstree command

$ pstree

Insert picture description here

top command

$ top

Insert picture description here

Kill process

$ kill <进程ID>

Guess you like

Origin blog.csdn.net/qq_18191333/article/details/107536043