I. Differences between programs and processes
1. A program is a static concept. It is stored as a software resource for a long time. A process is the execution process of a program. It is a dynamic concept and has a certain life cycle, is dynamically generated and extinct.
2. There is no one-to-one correspondence between programs and processes. A program can be shared by multiple processes. On the other hand, a process can execute several programs sequentially in the activity.
Ii. Parent process PPID and child process PID]
1. A child process is a process generated by a process. The process that generates this child process is called the parent process.
2. in Linux, use the system to call fork to create a process. Fork copies the data and stack segments of the parent process and the process environment of the parent process.
3. The parent process stops the child process and ends naturally.
4. Two Special Cases
(1) when the parent process is terminated, the child process still exists and becomes an orphan process, its automatic PPID points to init
(2) The child process dies, and the parent process does not know, and the child process becomes a zombie process.
3. foreground and background processes
Foreground process:
After hitting the command at the Shell prompt, create a sub-process [the parent process is Shell], run the command, Shell waits for the command to exit, and then return to the user to give a prompt. This command is run asynchronously with Shell, that is, on the foreground. You cannot execute another command before it is completed.
Background process:
Run the command in the Shell prompt. If the sub-process created by the Shell runs the command, the command is directly returned to the user without waiting for the command to exit. Run this command in sync with Shell, that is, run it in the background. The background process must be non-interactive.
For example, find/home-name init> test/tmp.txt
4. Process status
Ready state: the process has been allocated to resources, but because other processes are occupying the CPU, so temporarily unable to run and waiting for the CPU allocation status.
Waiting status: waiting for an event and temporarily unable to run.
Running status: the process is allocated to the CPU and is running on the processor.
5. Process status refinement
User-mode running: Execute user code on the CPU
Core running: execute core code on the CPU
In-memory ready: Has running conditions, only wait for the scheduler to allocate CPU for it
In-memory sleep: waiting in the memory for a certain event
In the external store ready: The ready process is switched to the external store and continues to be in the ready state.
Out-of-memory sleep: The sleep process is switched to the out-of-memory to continue waiting
Pause in memory: When the stop program is called, it enters the trace pause state and waits for its parent process to send a command.
Suspend External Storage: Processes in the tracking pause state are switched to external storage.
Creation state: the intermediate state in which the new process is being created but not completed
Terminating state: the process terminates itself.