From c73d4c832c3038c60c6ccffacfb2301051ec4570 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 14 Oct 1994 09:00:43 +0000 Subject: Formerly mgt.c.~21~ --- proc/mgt.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'proc') diff --git a/proc/mgt.c b/proc/mgt.c index be969132..aca3e151 100644 --- a/proc/mgt.c +++ b/proc/mgt.c @@ -463,7 +463,7 @@ new_proc (task_t task) mach_port_request_notification (mach_task_self (), p->p_task, MACH_NOTIFY_DEAD_NAME, 1, p->p_reqport, MACH_MSG_TYPE_MAKE_SEND_ONCE, &foo); - if (foo) + if (foo != MACH_PORT_NULL) mach_port_deallocate (mach_task_self (), foo); @@ -689,13 +689,29 @@ add_tasks (task_t task) int genpid () { - static int nextpid = 0; - #define WRAP_AROUND 30000 #define START_OVER 100 + static int nextpid = 0; + static int wrap = WRAP_AROUND; + + int wrapped = 0; + + while (!pidfree (nextpid)) + { + ++nextpid; + if (nextpid > wrap) + { + if (wrapped) + { + wrap *= 2; + wrapped = 0; + } + else + { + nextpid = START_OVER; + wrapped = 1; + } + } - while (!pidfree (nextpid) - && ((++nextpid > WRAP_AROUND) || (nextpid = START_OVER))) - ; return nextpid++; } -- cgit v1.2.3