The creation of processes programmed in C language in Linux-general Linux technology-Linux programming and kernel information. The following is a detailed description. Process Concept
The Linux operating system is intended for multiple users. At the same time, many users can issue various commands to the operating system. How does the operating system implement multi-user environments? In modern operating systems, there are procedures and processes. What are programs and processes? In general, a program is a file that contains executable code and is a static file. A process is an instance of a program that has started execution but has not ended. is the specific implementation of executable files.
A program may have many processes, and each process may have many sub-processes. and generate child processes. after a program is called to the memory by the system, the system allocates certain resources (memory, device, and so on) to the program and then performs a series of complex operations to turn the program into a process for the system to call. in the system, only processes have no programs. to distinguish different processes, the system assigns an ID (like our ID card) to each process for identification.
To make full use of resources, the system also differentiates processes from each other. processes are divided into five states: new, running, blocking, ready, and completed. "New" indicates that the process is being created, "running" means that the process is running, "blocking" means that the process is waiting for an event, and "ready" means that the system is waiting for the CPU to execute the command, completion indicates that the process has ended and the system is recycling resources. for a detailed explanation of the five States of a process, see operating system.
2. Process flag
As we know above that all processes have an ID, how can we get the ID of the process? The system calls getpid to get the ID of the process, while getppid can get the ID of the parent process (the process that creates the process that calls this function.