Re: random PID generation

bert hubert (ahu@ds9a.nl)
Fri, 23 Feb 2001 15:18:08 +0100


On Fri, Feb 23, 2001 at 02:20:27PM +0100, Heusden, Folkert van wrote:

> > With truly random PIDs, there is a much larger chance of a new process
> > sitting on a recently used PID.
>
> My code runs trough the whole task_list to see if a chosen pid is already
> in use or not.

But it doesn't check for a recently used PID. Lets say your system is
exhausting 1000 PIDs/second, and that there is a window of 20ms between you
determining which PID to send to, and the recipient process receiving it.

With truely random PIDs, there is now a chance of 1-(1-1/32000)^20 that a
new process will have the PID of the process you intended your signal for.
That's 0.06%, but historically, we care for those kind of chances.

The complete formula is: 1-(1-1/32000)^(dt*pps), where dt stands for the
time interval and pps for the number of pids created per second.

Currently, there are problems if your dt*pps product is bigger than 32000,
which in practice won't ever happen.

Regards,

bert hubert

-- 
http://www.PowerDNS.com      Versatile DNS Services  
Trilab                       The Technology People   
'SYN! .. SYN|ACK! .. ACK!' - the mating call of the internet
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/