summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2001-08-02 03:47:18 +0000
committerRoland McGrath <roland@gnu.org>2001-08-02 03:47:18 +0000
commitd4345d7eb14a96c4cf845db398ad0e8ad8752875 (patch)
treef4fcb5e350fb3925a42682544330490c1200576f
parent7623ec54a0fe4d5a5cc065de9478825854406a06 (diff)
2001-08-01 Roland McGrath <roland@frob.com>
* mgt.c (genpid): Rewritten.
-rw-r--r--proc/mgt.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/proc/mgt.c b/proc/mgt.c
index 1291a80b..3daf7dac 100644
--- a/proc/mgt.c
+++ b/proc/mgt.c
@@ -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++;