summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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++;