Linux Process Management related concepts

Source: Internet
Author: User
Tags switches

We know that, whether on a busy server or a relatively idle PC, the system is not just running a process on Linux, when the user enters a command that we call a process after the program is loaded into memory execution.

The core components of the computer, CPU and memory, the CPU is composed of the operator and the controller, the CPU can only read the data from the memory to calculate, then on the Linux system, when the user input a command, the command of the program code will be loaded into memory, and then executed by the CPU, It is important to switch between many processes because there are multiple processes that need to be executed while the CPU is only one.

We know that the computing power provided by the CPU is calculated by the passing of time, so for the process we can simply understand that the process is getting a certain amount of CPU time, the process is running on the CPU, such as the execution of the Cat/etc/fstab command, Cat this program needs to read/etc/fstab file contents of this file after the output to stdout, because the/etc/fstab file is stored on the hard disk, the ability to directly manipulate the hardware only the kernel, then the cat program will need to output through the kernel system calls to the kernel to initiate the request , from the kernel to read the contents of the/etc/fstab file from the hard disk to the memory, and then by the Cat program output, then the kernel read the file this time, the cat process will wait for the kernel output, or can not continue to run, in this case, in order to avoid the CPU wasted computing power, This process goes into non-disruptive sleep and switches other processes to the CPU. Also, when a process is executing on the CPU, if the CPU clock period allocated to the process is exhausted, the process should also exit and switch other processes to run.

In either case, the next time these processes continue to be scheduled to run on the CPU, you must continue from where you left off, which means that the process switch must save the relevant state information of the process when it switches out of the process, which we call the save site , that is, the information that the process executes on the CPU, such as the contents of the CPU registers in memory, when the process is scheduled to execute again, the kernel also needs to put this information back to its original location, this process is called the recovery site .

The

    kernel (i.e. system software) also needs to be executed on the CPU, which means that the kernel also needs to occupy memory resources, because the main function of the kernel is to manage the hardware resources, the space occupied by the memory kernel is called the kernel space. And the space occupied by the application is called the user space, in the user space is running a lot of processes, of course, process management needs to implement the kernel, then the kernel needs to know what processes on the current system and the relevant State property information of these processes, so the kernel needs to maintain a table structure for each process, The inside needs to place the PID of the process, the execution state information, this structure we call task-struct, so it is because the kernel maintains such a table structure, it can realize the scheduling of the process, save the scene and restore the scene. Whether it is on-site or on-site, it takes time for the kernel to keep the status information from the CPU registers in memory or back to the original location, so the Excessive process switching can significantly reduce system performance (the Apache Prefork model becomes a bottleneck for the system )

Every application needs memory resources, so how to effectively manage memory resources, if the application is running when the allocation of resources, then after a period of time, memory can easily produce a lot of fragments, And it is likely that a bug in one program overwrites the memory space of other processes, causing the process to not function properly. Therefore, the Linux management memory mechanism uses the concept of virtual memory or linear memory, which basically means that every process of user space on the system will not be aware of the existence of other processes, but only itself and the kernel, if on a 32-bit system, It will assume that its memory space is 4G (where the 1G kernel), the process is independent of each other, then the relevant data of each process will be placed in the same physical memory, then the conversion between virtual memory and linear memory is particularly important for the kernel, in order to avoid wasting resources, The physical memory is divided into a fixed size of the page box, and then the page boxes are also virtual memory page one by one corresponding to achieve the purpose of recording the structure of the transformation relationship we can understand it as a sub-structure of task-struct . We know that when the program runs, the program may load the dynamic library, 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M02/74/8E/ Wkiom1ygsw7cp4unaak3qesidt8668.jpg "title=" 3j86m@zqk7gn9ammj6jp5~f.png "alt=" Wkiom1ygsw7cp4unaak3qesidt8668.jpg " />

Memory Mapping Segment segment, This segment may not be necessary to load multiple times, so there are two ways to record the RAM, thevsz represents the virtual memory area (that is, the memory space occupied by standing in the perspective of a single application) ,RSS indicates that the resident memory is the amount of memory it occupies on real physical memory.

When the program is written, if there is no parallel programming method, then the process can only be run on a CPU, if the use of parallel, then the program will execute a number of execution flow, each execution flow can be executed on a CPU, so that can significantly improve system performance, This implementation flow concept we can simply understand it as a thread , in MySQL, for example, MySQL is high-performance because of multiple threads in parallel execution, so MySQL server generally high hardware requirements, but MySQL a thread can only be executed on one CPU

This article only helps to understand some related concepts and understand some of the process management related commands, so the description of the relatively shallow

This article is from the "Zxcvbnm Xuan ye" blog, please be sure to keep this source http://10764546.blog.51cto.com/10754546/1703557

Linux Process Management related concepts

Related Article

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.