Welcome to the Linux Foundation Forum!

PID(process ID)

Hi, i'am a newbie in linux,

i want to ask something about process id,

linux is multiprogramming system, so independent user process may be running at the same time and with different user,

it's said that the value of PID(process id) is from 1 to 32768, i want to ask how if there is more than 32768 process in a computer, what the new value PID of new process, how linux kernel implement this??

thanks very much....

Comments

  • marc
    marc Posts: 647
    That's the OS limit. It can't handle more than that number of processes (AFAIK). It's not like you going to get to that many processes in one computer, are you? ;)

    Regards
  • mfillpot
    mfillpot Posts: 2,177
    Very rarely would you exceed that many PIDs, however if the need comes up you can increase the maximum pids for the system, check http://www.cyberciti.biz/tips/howto-linux-increase-pid-limits.html for instructions.
  • Thanks, i think i get important information here,
    is in kernel the systemcall use "sysctl -w kernel.pid_max=4194303" itself or other similar syscall so linux automatically expand the pid on demand?

    and not a long time ago, i find :
    *PIDs are converted to matching process descriptors using a hash function.
    *A pidhash table maps PID to descriptor.
    *Collisions are resolved by chaining.

    Is "collision" above means process with same pid??
    if not, what does it mean?

    Sorry, if i ask much, but i really want to know more,
    btw, thanks for your information before








  • mfillpot
    mfillpot Posts: 2,177
    Yes, that command will expand it on demand, but it is best to set the value at boot time. When I tried the command on my system it errored out, so I am assuming that something is wrong with my custom kernel that is blocking the command.

    I think the document you are referring to is stating that it two processes have the same descriptors that the hash table uses a chain of values on the descriptor value to associate the processes. There should never be two processes with a single pid value.
  • Ouu, i see know, thanks, that's really a help,
  • "collision" , are refers to the hash table entries

    using open addressing also collisions can be avoided.
    Linux uses chaining, where the data entry hashes are filled with linked list of indexes of the data

    As mfillpot mentioned, two processes can not have same PIDs. Linux will assign a PID to a process and if the process is finished, that PID get used, once the PID limit in OS exceeds and started to assign the PID again from 2 onwards. [ start from beginning. ]

Categories

Upcoming Training