Linux Process Management

Source: Internet
Author: User

I. Concept and classification of processes

1. The concept of the process
       linux is a multi-user multitasking operating system. Multi-user refers to multiple users can use the same Linux system at the same time, multi-tasking is to be able to perform multiple tasks under Linux, in more detail, Linux uses the method of time-sharing management, all tasks are placed in a queue, Depending on the priority of each task, the operating system allocates the appropriate time slices for each task, each time slice is short, and the user does not feel that multiple tasks are running, so that all tasks share system resources, so that Linux can suspend this task temporarily while one task is not finished, and then perform another task. Come back to the task after a while, until the task is completed and removed from the task queue. This is the concept of multitasking.
        above is the case of a single CPU multitasking operating system, in which the system can run multiple tasks, but at a certain point in time, The CPU can only perform one process, and in a multi-CPU multitasking operating system, because there are multiple CPUs, at some point in time, multiple processes can run concurrently.
        process is a standalone program that runs in its own virtual address space, from the operating system perspective, Everything that runs on the system can be called a process.
        Note that there is a difference between the program and the process, although the process has a program, but it is not a program, the program is a set of process instructions, It can enable one or more processes, at the same time, the program only consumes disk space, and does not occupy the system running resources, and the process only occupies the system memory space, is dynamic, variable, shutdown process, the memory resources used to release.
2. Classification of the process

Depending on the function of the process and the program being run, the process can be divided into two main categories:
(1) System process: can perform the management of memory resource allocation and process switching, and the running of the process is not affected by the user, even the root user cannot interfere with the operation of the system process.
(2) User process: processes generated by executing user programs, applications, or system programs outside the kernel, which can be run or shut down under the control of the user.
For the user process, but also can be divided into interactive process, batch process and daemon three categories.
(3) Interactive process: a process initiated by a shell terminal, which needs to interact with the user during execution, can be run in the foreground, or run in the background.
(4) Batch process: The process is a collection of processes that are responsible for starting other processes sequentially.
(5) Daemon: A daemon is a process that is always running, which is often started when the Linux system starts and terminates when the system shuts down. They are independent of the control terminal and periodically perform certain tasks or wait to handle certain occurrences. For example, the httpd process, which is running, waits for the user's access. There are also frequently used crond processes, which are similar to the Windows scheduled tasks that can periodically perform certain tasks that the user sets.

3. Properties of the process
(1) Several states of the process, the process after the start, not necessarily start running immediately, so there are many kinds of processes.
       Operational status: A process in this state that is either running or ready to run.
interruptible wait state: This type of process is in a blocking state, and once a condition is reached, it becomes a running state. At the same time, the process of this state will be awakened into the running state due to the reception of the signal.
Non-disruptive wait state: basically similar to the meaning of interruptible wait state, the only difference is that the process in this state does not respond to the signal.
Zombie State: The zombie process, where each process ends up in a zombie state, waits for the parent process to call to release the resource, the process in that State has ended, but its parent process has not yet freed its system resources.
Paused state: Indicates that the process at this time is temporarily stopped to receive some special processing,
(2) The relationship between processes
In Linux systems, process IDs (represented by PID) are unique identities that differentiate between different processes, with limited size, a maximum ID of 32768, and a UID and GID that represent the user and user groups that started the process. All processes are descendants of the init process with PID 1, and the kernel starts the INIT process at the end of the system startup, so the process is the parent of all processes under Linux, and the parent process is represented by Ppid.
The following is the SendMail process information that is output through the PS command:

[[email protected] ~]# Ps-ef | grep  sendmail

In relation to the parent process, there is a child process, generally each process must have a parent process, the parent process and the child process between the management and the managed relationship, when the parent process stops, the child process disappears, but the child process is closed, the parent process does not necessarily terminate.
If the parent process exits before the child process exits, then all child processes become an orphan process, and if there is no corresponding processing mechanism, the orphan process will be in a zombie state, the resources cannot be released, at this time the solution is to find a process within the initiation process as the parent process of these orphan processes, Or simply let the INIT process act as their parent process, freeing up the resources that the orphan process consumes.

Ii. monitoring and management of the process
         Linux, There are many commands for monitoring and managing processes, and the following are the four most commonly used instructions for PS, top, Pstree, lsof if you are effectively monitoring and managing various processes under Linux.

1. using top monitoring system processes

The use of the top command, in the fourth chapter has been introduced in detail, here through a few examples, explain the top command in the system process monitoring the role and advantages.

Linux Process Management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.