ref: fa03455b5057675b18d1c87aef2d1071b2088de0
parent: 6a057511327e7ab355e42919a8195db582640ce0
author: cinap_lenrek <[email protected]>
date: Mon Jun 23 17:51:34 EDT 2014
kernel: more proc.c cleanup
--- a/sys/src/9/port/proc.c
+++ b/sys/src/9/port/proc.c
@@ -120,7 +120,7 @@
m->machno,
m->ilockdepth,
up != nil ? up->lastilock: nil,
- (up != nil && up->lastilock) ? up->lastilock->pc: 0,
+ (up != nil && up->lastilock != nil) ? up->lastilock->pc: 0,
getcallerpc(&p+2));
if(up != nil) {
/*
@@ -486,7 +486,7 @@
if(npri != pri){
x = splhi();
p = dequeueproc(rq, p);
- if(p)
+ if(p != nil)
queueproc(&runq[npri], p);
splx(x);
goto another;
@@ -714,15 +714,14 @@
Proc *p;
int i;
- procalloc.free = xalloc(conf.nproc*sizeof(Proc));
- if(procalloc.free == nil){
+ p = xalloc(conf.nproc*sizeof(Proc));
+ if(p == nil){
xsummary();
panic("cannot allocate %lud procs (%ludMB)", conf.nproc, conf.nproc*sizeof(Proc)/(1024*1024));
}
- procalloc.arena = procalloc.free;
-
- p = procalloc.free;
- for(i=0; i<conf.nproc-1; i++,p++)
+ procalloc.arena = p;
+ procalloc.free = p;
+ for(i=0; i<conf.nproc-1; i++, p++)
p->qnext = p+1;
p->qnext = nil;
}
@@ -1223,10 +1222,7 @@
static int
haswaitq(void *x)
{
- Proc *p;
-
- p = (Proc *)x;
- return p->waitq != 0;
+ return ((Proc*)x)->waitq != nil;
}
ulong
@@ -1308,10 +1304,8 @@
print("no current process\n");
for(i=0; i<conf.nproc; i++) {
p = &procalloc.arena[i];
- if(p->state == Dead)
- continue;
-
- dumpaproc(p);
+ if(p->state != Dead)
+ dumpaproc(p);
}
}
@@ -1556,7 +1550,7 @@
ep = procalloc.arena+conf.nproc;
for(p = procalloc.arena; p < ep; p++)
- if(p->user!=nil && strcmp(old, p->user)==0)
+ if(p->user != nil && strcmp(old, p->user) == 0)
kstrdup(&p->user, new);
}