A Process Identification Number, or 'pid', used to differentiate between processes in a multi-process computing environment.

For users:

When you run the common UNIX command 'ps', you get a list of processes and their respective pid numbers. With this information, you can perform actions such as killing processes, and sending them signals (using the 'kill' command).

In depth:

pid numbers in a UNIX system are usually positive integers of 15 bits. This gives them a range of 0-32767. pid numbers are assigned to processes in an incremental way. It means that a 'last assigned pid number' variable is kept in the system and upon the creation of new processes this variable gets incremented and the pid numbers are given to the new processes according to its value.

When a UNIX system boots, pid 1 is assigned to the first process, which is the init process. The system call used in UNIX to create processes is 'fork' (or sometimes 'vfork, 'clone'). init forks daemon programs, and these daemons get low pid numbers. After roughly 32767 forks, the pid assignment cycles back to 1, and processes are again being assigned with low pid numbers. Thus, a new process can be assigned with a pid of a previously dead process. On several systems, incremental increases are not a must. In fact several OSes choose them randomly for security reasons. On other systems, pid numbers lower than a certain limit are restricted to kernel-level threads.

Linux in particular: It has 15-bit pid numbers, though according to Linus Torvalds, there is no real problem to switch to 32-bit pid numbers, except for the uncertainty of how pid numbers should be handled in clustering environments. pid numbers lower than a certain limit are restricted to kernel-level threads, and on cycles the pid assignment variable resets to 300 instead of 1. In the Linux implementation, there is no difference between processes and threads, and each thread has it's own pid number. This is changing as recent kernels implement a better thread model, supporting lightweight processes.

Log in or register to write something here or to contact authors.