diff options
author | Roland McGrath <roland@gnu.org> | 2001-08-02 03:47:18 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2001-08-02 03:47:18 +0000 |
commit | d4345d7eb14a96c4cf845db398ad0e8ad8752875 (patch) | |
tree | f4fcb5e350fb3925a42682544330490c1200576f /proc | |
parent | 7623ec54a0fe4d5a5cc065de9478825854406a06 (diff) |
2001-08-01 Roland McGrath <roland@frob.com>
* mgt.c (genpid): Rewritten.
Diffstat (limited to 'proc')
-rw-r--r-- | proc/mgt.c | 30 |
1 files changed, 8 insertions, 22 deletions
@@ -677,7 +677,7 @@ static struct proc * new_proc (task_t task) { struct proc *p; - + p = allocate_proc (task); if (p) complete_proc (p, genpid ()); @@ -846,30 +846,16 @@ genpid () static int nextpid = 0; static int wrap = WRAP_AROUND; - int wrapped = 0; - - if (nextpid > wrap) + while (nextpid < wrap && !pidfree (nextpid)) + ++nextpid; + if (nextpid >= wrap) { nextpid = START_OVER; - wrapped = 1; - } + while (!pidfree (nextpid)) + nextpid++; - while (!pidfree (nextpid)) - { - ++nextpid; - if (nextpid > wrap) - { - if (wrapped) - { - wrap *= 2; - wrapped = 0; - } - else - { - nextpid = START_OVER; - wrapped = 1; - } - } + while (nextpid > wrap) + wrap *= 2; } return nextpid++; |