lkml.org 
[lkml]   [2000]   [Jan]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Why wrapping PIDs is evil [was 32bit]
Date
On Sun, 16 Jan 2000 01:33:04 -0500 (EST), 
Stephen Frost <sfrost@mail.snowman.net> wrote:
>On Fri, 14 Jan 2000, Pavel Machek wrote:
>The very _nice_ thing about Unix is that it wraps pids and does _not_
>pick random pids. You shouldn't get around to the same pid for at
>least a reasonable amount of time, unless someone is spawning processes
>_very_ fast.

Depends on the version of "Unix". IBM's Unix System Services (Unix for
MVS) uses 32 bit pids structured like this - big endian.

Bit 0 - 0
Bit 1-7 - slot usage counter
Bit 8-15 - reserved, currently 0
Bit 16-31 - pid slot number.

USS allows for 64K of pid slots. When creating a process, it uses the
first free slot, incrementing the slot usage counter to make the pid
numbers "unique". If a parent forks 128 times and the child exits each
time and no other process is created (so USS picks the same free slot
each time), then the 32 bit pid will wrap after 128 forks. I can do
that in under 2 seconds.

Or to put it another way, any code that relies on a reasonable time
between pid reuse is "forked". It is not guaranteed by Unix nor Posix.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.990 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site