Each process has a unique process ID represented by a non-negative integer. Although it is unique, the process ID can be reused (after a process is terminated, its process ID can be used again ). Most Unix systems implement latency reuse algorithms.
A process whose ID is 0 is usually a scheduling process, which is often called a Swapper ). This process is a part of the kernel. It does not execute any program on the disk and is also called a system process.
Id 1 is usually the INIT process, which is called by the kernel at the end of the Self-lifting process. This process starts a UNIX system after the bootstrap kernel. Init usually reads system-related Initialization Files (/etc/rc * file or/etc/inittab file, and/etc/init. d), and direct the system to a State (for example, multiple users ). Init is not always terminated, and it is a common user process, not a system process in the kernel process.
A process with ID 2 is a page daemon of Some UNIX systems and is responsible for supporting paging operations on the virtual storage system.
# Include <unistd. h>
Pid_t getpid (void); // obtain the ID of the process called.
Pid_t getppid (void); // obtain the parent process ID of the calling Process