From d7f90a909637fcf12f564fa65b53a1416bef1f6c Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 7 Dec 2013 08:25:26 +0100 Subject: kernel: simplify pexit(), avoid making wait record for RFNOWAIT (parentless) procs replaced the p->pid != 0 check with up->parentpid != 0 so p->pid == up->parentpid is never true for p->pid == 0. avoid allocating the wait records when up->parentpid == 0. --- sys/src/9/port/proc.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sys/src/9/port/proc.c b/sys/src/9/port/proc.c index ed549fb75..8f3817b57 100644 --- a/sys/src/9/port/proc.c +++ b/sys/src/9/port/proc.c @@ -1111,14 +1111,7 @@ pexit(char *exitstr, int freemem) * if not a kernel process and have a parent, * do some housekeeping. */ - if(up->kp == 0) { - p = up->parent; - if(p == 0) { - if(exitstr == 0) - exitstr = "unknown"; - panic("boot process died: %s", exitstr); - } - + if(up->kp == 0 && up->parentpid != 0) { wq = smalloc(sizeof(Waitq)); wq->w.pid = up->pid; utime = up->time[TUser] + up->time[TCUser]; @@ -1131,11 +1124,12 @@ pexit(char *exitstr, int freemem) else wq->w.msg[0] = '\0'; + p = up->parent; lock(&p->exl); /* * Check that parent is still alive. */ - if(p->pid != 0 && p->pid == up->parentpid && p->state != Broken) { + if(p->pid == up->parentpid && p->state != Broken) { p->nchild--; p->time[TCUser] += utime; p->time[TCSys] += stime; @@ -1158,6 +1152,11 @@ pexit(char *exitstr, int freemem) if(wq) free(wq); } + else if(up->kp == 0 && up->parent == 0){ + if(exitstr == 0) + exitstr = "unknown"; + panic("boot process died: %s", exitstr); + } if(!freemem) addbroken(up); -- cgit v1.2.3