Home  >  Article  >  Operation and Maintenance  >  What is the difference between process and program in linux

What is the difference between process and program in linux

青灯夜游
青灯夜游Original
2022-07-01 19:25:323886browse

The difference between a process and a program in Linux: 1. A program is static, it is just a set of instructions and does not have any operational significance; while a process is dynamic, it is a dynamic process of program running. 2. The life cycle of a process is relatively short-lived, while a program is permanent. 3. One process can only correspond to one program, and one program can correspond to multiple processes. 4. The process has concurrency and interactivity, but the program does not. It is closed.

What is the difference between process and program in linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

1. What is a program?

A program is a set of instructions to complete a specific task

2. What is a process?

From the user's point of view, a process is a dynamic execution process of a program.

From the core of the operating system, a process is the memory, CPU time slice and other resources allocated by the operating system. the basic unit.

Process is the smallest unit of resource allocation

Each process has its own independent address space and execution status.

Multi-tasking operating systems like UNIX can allow many programs to run at the same time. Each running program constitutes a process

3. Process data structure

Static description of the process: It consists of three parts: PCB, relevant program segments and a set of data structures that the program segments operate on.

Process Control Block (PCB): Used to describe the process situation and control all the information required to run the process. It is an important data structure used by the operating system to sense the existence of the process.

Code segment: It is a program code segment in the process that can be executed on the CPU by the process scheduler.

Data segment: The data segment of a process, which can be the original data processed by the program corresponding to the process, or the intermediate or final data generated after the program is executed.

Process = code segment ( Some instructions formed after compilation) Data segment (data required when the program is running) Stack segment (some memory dynamically allocated when the program is running) PCB (process information, status identification, etc.)

Data segment includes:

  • Read-only data segment: constant

  • Initialized data segment: global variable, static variable

  • Bit initialization data segment (bss) (0 initialization segment): uninitialized global variables and static variables (no memory is actually allocated, because they are all 0, only some tag information)

4. The difference between process and program

1. The process is dynamic and the program is static

The program is static. It is just a set of instructions and does not have any operational significance. The process is the dynamic process of program running

2. The life cycle of the process is relatively short-lived, while the program is permanent.

3. One process can only correspond to one program, and one program can correspond to multiple processes.

Processes and programs are not in a one-to-one correspondence. The same program running on different data sets is a different process

4. Processes also have concurrency and interaction, while programs But it is closed

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of What is the difference between process and program 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