Home  >  Article  >  Operation and Maintenance  >  What is a process in linux

What is a process in linux

angryTom
angryTomOriginal
2019-11-06 14:49:373471browse

What is a process in linux

#What is a process in Linux?

A process, in layman’s terms, is an ongoing program, a running program, also called PCB (process control block)

Under the Linux operating system, a process is described A structure called task_struct, so what does this structure contain?

We all know that in order for a program to run, it must first load the corresponding executable file from the disk into the memory. So how do we know where it is in the memory? At this time, you need to find it through something called a process identifier (pid). Just like us, we have something that represents our identity, that is, an ID card.

After finding where the program is, if you want to execute it, you must know the corresponding code and the data the code depends on, so the memory pointer was born. Memory pointers are used to point to program code and corresponding data. The program is now ready to run.

However, since there are many processes, and generally there is only one central processing unit (CPU), in order to ensure the smooth implementation of many processes, there needs to be an order of execution between processes, that is, priority. It is much easier to implement multiple processes after having priorities.

But it is worth noting that the CPU does not execute one process before executing the next one. It will execute the next process after one program has been executed for a period of time, and then the next process has been executed for a period of time. Then execute subsequent processes. At this time, a problem will arise. What should I do if an unexecuted program wants to continue execution from the previous place? Don’t worry, we’ll protect the scene with “context”.

As mentioned earlier, a program will be executed for a period of time before the CPU will execute the next program. So how long should a program be executed before the CPU gives up? Here we use "accounting information" to record this time.

In addition, the process will appear in many states during execution, such as ready state (R), interruptible sleep state (S), uninterruptible sleep state (D), etc., so there are also Record the status of the process. Of course, there is also I/O status information, namely standard input, standard output, and standard error output.

To sum up, a task_struct, a structure describing a process, contains the following parts:

● Identifier: used to record the id of the process, that is, pid

● Memory pointer : Points to the program code and related data, etc.

● Priority;

● Context: Saves the last execution site of the process on the CPU

● Accounting information: Recorded when a process should give up the CPU

● Status: Recorded process-related status

● I/O status information;

● Signal-related information

Recommended: linux system basic tutorial

The above is the detailed content of What is a process in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn