Messages in this thread | | | From | Keith Owens <> | Subject | Re: Why wrapping PIDs is evil [was 32bit] | Date | Sun, 16 Jan 2000 18:11:16 +1100 |
| |
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/
| |