Process Control (ii)---process identifier

Source: Internet
Author: User

in order to differentiate each process in the Linux operating system, each process is assigned a unique process number, also known as the process ID. The process ID is stored in the process's PCB and belongs to the kernel resource of the process. the process ID of each process is unique, but the process ID can be reused, and when a process is terminated, all its resources are freed, including the process ID. When the system creates a new process again, it can be assigned a process ID that has already been disposed. Because the operating system employs a deferred reuse algorithm, the process ID assigned to the process that was just created is usually not the process ID that was just released. The process ID of some processes in the operating system is fixed, such as the process ID of the 0,init process for the scheduling process is 1. These processes are special processes. ======================================================================As mentioned earlier, the process ID is stored in the process's PCB and belongs to the kernel resource of the process, so it is not possible to get the process ID directly in the user space, and it must be obtained through the system call. Here are a few system callsfunction Prototypes:return Value:
    • This function does not go wrong, it always returns process ID of the process
function Prototypes:return Value:
    • The same error will always return the parent process ID of this process
function Prototypes:return Value:
    • These two functions also do not go wrong, always returning the actual user ID of the process and the valid user ID of the process
Note: The process ID in these system calls uses the pid_t type, and the user ID uses the uid_t type. You should also use this type to define variables later when you write your program.

Process Control (ii)---process identifier

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.