pid rollover?

Greg Noel greg at ncr-sd.SanDiego.NCR.COM
Mon Feb 13 19:44:55 AEST 1989


In article <11212 at ulysses.homer.nj.att.com> smb at ulysses.homer.nj.att.com
(Steven M. Bellovin) writes:
>Many years ago, I saw a mod to a V6 UNIX(r) system that used the process
>table slot as the low-order 8 bits of the pid, and incremented a counter
>in the high-order bits to ensure that a pid wasn't reused too soon.

I confess -- I did it.  It seemed to me that the computer would be wasting
a lot of time looking through the process table to see if a PID was already
in use, so I dreamed up the hack of using the low-order bits as the table
index to avoid the search.  It was OK on a PDP-11/40, but on a PDP-11/70
we were approaching the maximum number of processes, and the process
numbers themselves were cycling too fast -- if processes were being created
and dying rapidly, the same process slot tended to be reused, so after 128
tries, the same PID came up again.  Replacing the free-process stack with
a queue so that different process slots were being used simply put back in
the overhead that removing the search had taken out.

But the real killer was that I could never measure any performance improvement
and the code required was bigger.  Since space was always tight (you youngsters
haven't lived until you've shoehorned a full networking kernel into 49,152
bytes) I eventually took it out.

(MO, would this be another Greg Noel Hack?)
-- 
-- Greg Noel, NCR Rancho Bernardo   Greg.Noel at SanDiego.NCR.COM  or  greg at ncr-sd



More information about the Comp.unix.wizards mailing list