Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-25-2014, 07:17 AM   #1
Registered: Jun 2013
Posts: 71

Rep: Reputation: Disabled
Processes / Pid Assignment

According to course material :

"Processes are assigned pids in sequential order. Eventually the system will read the maximum pid value which is defined in /proc/sys/kernel/pid_max. Once the maximum pid value is reached, the system will roll over and assign future pids from the bottom of the range."

This is a little confusing. I understand the need to rollover obviously. But what exactly does "from the bottom of the range" ?

So right now in a VM I access 32768 is defined in pid_max. When the system reaches this number ... does it roll back to 1 (well actually 2) or, in example, if 32600 is free, will that number be assigned to the next process ?

I wanted to edit this to clarify the question a little bit..

Systems talking to us
"Ive reached the max pid of 32768."
"Start from the bottom and see if 32767 is open"
"No check 32766"
"Yes assign 32767 to new process"


Systems talking to us
"Ive reached the max pid of 32768."
"Start from the top and see if 2 is open"
"No check 3"
"Yes assign 2 to new process"

Thanks alot for the help !

Last edited by sumncguy; 11-25-2014 at 07:53 AM.
Old 11-25-2014, 07:33 AM   #2
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,124
Blog Entries: 10

Rep: Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815Reputation: 1815
It will return to 1 and use that, but only if 1 is free. The earliest process numbers many times end up being assigned to services which never terminate. If you perform "ps -e" you should see all processes and their PIDs which are currently in use. Therefore it will choose the next available PID value which isn't being used by another process.

Like on my system, 1, 2, and 3 are still taken. 4 is unused, so if/when my PIDs wrap, it will eventually use 4, and next 5. But since 6, 7, and 8 are taken, it will skip those and use 9.

$ ps -ef
root         1     0  0 Nov21 ?        00:00:00 /sbin/init
root         2     0  0 Nov21 ?        00:00:00 [kthreadd]
root         3     2  0 Nov21 ?        00:00:04 [ksoftirqd/0]
root         6     2  0 Nov21 ?        00:00:00 [migration/0]
root         7     2  0 Nov21 ?        00:00:00 [watchdog/0]
root         8     2  0 Nov21 ?        00:00:00 [migration/1]
root        10     2  0 Nov21 ?        00:00:05 [ksoftirqd/1]
root        12     2  0 Nov21 ?        00:00:00 [watchdog/1]
root        13     2  0 Nov21 ?        00:00:00 [cpuset]
root        14     2  0 Nov21 ?        00:00:00 [khelper]
1 members found this post helpful.
Old 11-25-2014, 07:50 AM   #3
Registered: Jun 2013
Posts: 71

Original Poster
Rep: Reputation: Disabled
Ok thanks thats what I thought .. but the text wording is a little confusing.

Thanks man !!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Confluence PID issue. (Removing/clearing stale PID file) vignesh4sh Linux - Server 5 12-05-2012 07:14 AM
[SOLVED] /proc/pid/maps files empty for all processes alexroux Linux - Kernel 6 02-16-2010 10:05 AM
su processes child of pid 1? acid_kewpie Linux - Software 5 07-29-2009 01:22 PM
How to read in a processes PID thedarkdestroyer Programming 3 05-09-2006 06:48 PM
/var/run/[XXX].pid - Tcl pid code liguorir Linux - Software 1 05-20-2004 10:32 PM

All times are GMT -5. The time now is 06:04 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration