From 98f47d5867cbbaa06f2c9080c301c9191e196205 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Fri, 22 Nov 2013 22:56:34 +0100 Subject: [PATCH] kernel: more kproc pexit() and sleep error handling --- sys/src/9/bitsy/power.c | 4 +++- sys/src/9/bitsy/wavelan.c | 4 +++- sys/src/9/ip/il.c | 2 ++ sys/src/9/ip/rudp.c | 2 ++ sys/src/9/ip/tcp.c | 3 +++ sys/src/9/kw/ether1116.c | 2 ++ sys/src/9/mtx/mmu.c | 3 +++ sys/src/9/ppc/mmu.c | 3 +++ sys/src/9/teg2/ether8169.c | 2 ++ sys/src/9/teg2/main.c | 1 - 10 files changed, 23 insertions(+), 3 deletions(-) diff --git a/sys/src/9/bitsy/power.c b/sys/src/9/bitsy/power.c index 1c495a160..50abbd02e 100644 --- a/sys/src/9/bitsy/power.c +++ b/sys/src/9/bitsy/power.c @@ -237,6 +237,9 @@ powerkproc(void*) { ulong xlink, xlink1; + while(waserror()) + ; + for(;;){ while(powerflag == 0) sleep(&powerr, powerdown, 0); @@ -247,7 +250,6 @@ powerkproc(void*) deepsleep(); xlink1 = getcallerpc(&xlink1); - delay(2000); // iprint("deepsleep returned, pc = 0x%lux, sp = 0x%lux\n", xlink1, &xlink); diff --git a/sys/src/9/bitsy/wavelan.c b/sys/src/9/bitsy/wavelan.c index 5d12eca62..d52ff1f85 100644 --- a/sys/src/9/bitsy/wavelan.c +++ b/sys/src/9/bitsy/wavelan.c @@ -682,6 +682,8 @@ w_timer(void* arg) Ctlr* ctlr = (Ctlr*)ether->ctlr; ctlr->timerproc = up; + while(waserror()) + ; for(;;){ tsleep(&up->sleep, return0, 0, MSperTick); ctlr = (Ctlr*)ether->ctlr; @@ -732,7 +734,7 @@ w_timer(void* arg) } iunlock(ctlr); } - pexit("terminated", 0); + pexit("terminated", 1); } void diff --git a/sys/src/9/ip/il.c b/sys/src/9/ip/il.c index c6e36e0ef..478fd4101 100644 --- a/sys/src/9/ip/il.c +++ b/sys/src/9/ip/il.c @@ -1145,6 +1145,8 @@ ilackproc(void *x) il = x; + while(waserror()) + ; loop: tsleep(&up->sleep, return0, 0, Iltickms); for(s = il->conv; s && *s; s++) { diff --git a/sys/src/9/ip/rudp.c b/sys/src/9/ip/rudp.c index f3e205aba..8f3de5e6d 100644 --- a/sys/src/9/ip/rudp.c +++ b/sys/src/9/ip/rudp.c @@ -733,6 +733,8 @@ relackproc(void *a) rudp = (Proto *)a; + while(waserror()) + ; loop: tsleep(&up->sleep, return0, 0, Rudptickms); diff --git a/sys/src/9/ip/tcp.c b/sys/src/9/ip/tcp.c index 6099b0308..d1addc9d7 100644 --- a/sys/src/9/ip/tcp.c +++ b/sys/src/9/ip/tcp.c @@ -747,6 +747,9 @@ tcpackproc(void *a) tcp = a; priv = tcp->priv; + while(waserror()) + ; + for(;;) { tsleep(&up->sleep, return0, 0, MSPTICK); diff --git a/sys/src/9/kw/ether1116.c b/sys/src/9/kw/ether1116.c index b60c70a49..c119f2aa2 100644 --- a/sys/src/9/kw/ether1116.c +++ b/sys/src/9/kw/ether1116.c @@ -776,6 +776,8 @@ rcvproc(void* arg) ether = arg; ctlr = ether->ctlr; + while(waserror()) + ; for(;;){ tsleep(&ctlr->rrendez, gotinput, ctlr, 10*1000); ilock(ctlr); diff --git a/sys/src/9/mtx/mmu.c b/sys/src/9/mtx/mmu.c index c43a1a7dd..6d14aaa1c 100644 --- a/sys/src/9/mtx/mmu.c +++ b/sys/src/9/mtx/mmu.c @@ -76,6 +76,9 @@ mmusweep(void*) int i, x, sweepcolor; ulong *ptab, *ptabend, ptecol; + while(waserror()) + ; + for(;;) { if(PIDCOLOR(m->mmupid) != m->trigcolor) sleep(&m->sweepr, work, nil); diff --git a/sys/src/9/ppc/mmu.c b/sys/src/9/ppc/mmu.c index 73155e448..c2997072e 100644 --- a/sys/src/9/ppc/mmu.c +++ b/sys/src/9/ppc/mmu.c @@ -80,6 +80,9 @@ mmusweep(void*) int i, x, sweepcolor; ulong *ptab, *ptabend, ptecol; + while(waserror()) + ; + for(;;) { if(PIDCOLOR(m->mmupid) != m->trigcolor) sleep(&m->sweepr, work, nil); diff --git a/sys/src/9/teg2/ether8169.c b/sys/src/9/teg2/ether8169.c index 0f3b1ec9d..67f3bdc90 100644 --- a/sys/src/9/teg2/ether8169.c +++ b/sys/src/9/teg2/ether8169.c @@ -855,6 +855,8 @@ rproc(void* arg) edev = arg; ctlr = edev->ctlr; + while(waserror()) + ; for(;;){ /* wait for next interrupt */ ilock(&ctlr->reglock); diff --git a/sys/src/9/teg2/main.c b/sys/src/9/teg2/main.c index b3bf81e17..4c4df93ce 100644 --- a/sys/src/9/teg2/main.c +++ b/sys/src/9/teg2/main.c @@ -692,7 +692,6 @@ init0(void) poperror(); } kproc("alarm", alarmkproc, 0); -// kproc("startcpusproc", startcpusproc, nil); touser(sp); }