kernel: kproc error and exit

catch the error() that can be thrown by sleep() and tsleep()
in kprocs.

add missing pexit() calls.

always set the freemem argument to pexit() from kproc otherwise
the process gets added to the broken list.
This commit is contained in:
cinap_lenrek 2013-11-22 22:28:20 +01:00
parent 91c7e0b127
commit df6b68092c
7 changed files with 20 additions and 7 deletions

View file

@ -13,6 +13,9 @@ alarmkproc(void*)
Proc *rp; Proc *rp;
ulong now; ulong now;
while(waserror())
;
for(;;){ for(;;){
now = MACHP(0)->ticks; now = MACHP(0)->ticks;
qlock(&alarms); qlock(&alarms);

View file

@ -701,8 +701,10 @@ loop:
} }
runlock(&devs); runlock(&devs);
i = Nms - TK2MS(Ticks - starttick); i = Nms - TK2MS(Ticks - starttick);
if(i > 0) if(i > 0 && !waserror()){
tsleep(&up->sleep, return0, 0, i); tsleep(&up->sleep, return0, 0, i);
poperror();
}
goto loop; goto loop;
} }

View file

@ -908,6 +908,8 @@ sdpackproc(void *a)
int i; int i;
Conv *c; Conv *c;
while(waserror())
;
for(;;) { for(;;) {
tsleep(&up->sleep, return0, 0, 1000); tsleep(&up->sleep, return0, 0, 1000);
sec = TK2SEC(m->ticks); sec = TK2SEC(m->ticks);

View file

@ -530,6 +530,8 @@ segmentkproc(void *arg)
incref(g->s); incref(g->s);
up->seg[sno] = g->s; up->seg[sno] = g->s;
while(waserror())
;
for(done = 0; !done;){ for(done = 0; !done;){
sleep(&g->cmdwait, cmdready, g); sleep(&g->cmdwait, cmdready, g);
if(waserror()){ if(waserror()){
@ -554,6 +556,8 @@ segmentkproc(void *arg)
g->cmd = Cnone; g->cmd = Cnone;
wakeup(&g->replywait); wakeup(&g->replywait);
} }
pexit("done", 1);
} }
Dev segmentdevtab = { Dev segmentdevtab = {

View file

@ -42,10 +42,11 @@ genrandom(void*)
up->basepri = PriNormal; up->basepri = PriNormal;
up->priority = up->basepri; up->priority = up->basepri;
while(waserror())
;
for(;;){ for(;;){
for(;;) if(++rb.randomcount <= 100000)
if(++rb.randomcount > 100000) continue;
break;
if(anyhigher()) if(anyhigher())
sched(); sched();
if(!rbnotfull(0)) if(!rbnotfull(0))

View file

@ -147,12 +147,11 @@ pager(void *junk)
Segment *s; Segment *s;
Proc *p, *ep; Proc *p, *ep;
if(waserror())
panic("pager: os error");
p = proctab(0); p = proctab(0);
ep = &p[conf.nproc]; ep = &p[conf.nproc];
while(waserror())
;
loop: loop:
up->psstate = "Idle"; up->psstate = "Idle";
wakeup(&palloc.r); wakeup(&palloc.r);

View file

@ -2225,6 +2225,8 @@ ehcipoll(void* a)
hp = a; hp = a;
ctlr = hp->aux; ctlr = hp->aux;
poll = &ctlr->poll; poll = &ctlr->poll;
while(waserror())
;
for(;;){ for(;;){
if(ctlr->nreqs == 0){ if(ctlr->nreqs == 0){
if(0)ddprint("ehcipoll %#p sleep\n", ctlr->capio); if(0)ddprint("ehcipoll %#p sleep\n", ctlr->capio);