Process Creation using C language in Linux

Source: Internet
Author: User
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.
QUOTE:

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.