Re: PID sequences

Rik van Riel (
Tue, 24 Feb 1998 10:59:09 +0100 (MET)

On Mon, 23 Feb 1998, Jim Nance wrote:

> I have seen severl posts (over the last couple of years) where
> people complained about either performance or security problems related
> to generating PID numbers for child processes at fork() time. There is
> the assumption that PID numbers increase, skipping over in-use PIDs,
> and then wrap at 32K. I dont think Digital Unix does it this way:
> This looks almost random, and it does not seem to break anything.
> I just wanted to let people know that if we wanted to use some other
> scheme for generating PIDs, there is some precident for doing so.

It could be done, but it would surely cost a little
A very cheap way to do it would be to:
- make a used/unused PID bitmap
- divide that bitmap into HZ pieces
- look into the 'jiffies'th part if there's some free PID
- if not, try the next area

But still, it might put us behind QNX and Lynx in forking
speed :-)

| For Linux mm-patches, go to | "I'm busy managing memory.." |
| my homepage (via LinuxHQ). | |
| ...submissions welcome... | |

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to