PROC_DYING cases handled
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 28 Feb 2011 22:05:26 +0000 (14:05 -0800)
committerKevin Klues <klueska@cs.berkeley.edu>
Thu, 3 Nov 2011 00:35:59 +0000 (17:35 -0700)
Yield and tlbshootdown can handle a dying process.  Should get rid of
annoying warnings/panics.

kern/src/process.c
kern/src/resource.c

index 1ee1836..3fb5a7d 100644 (file)
@@ -822,6 +822,10 @@ void proc_yield(struct proc *SAFE p, bool being_nice)
                                schedule_proc(p);
                        }
                        break;
+               case (PROC_DYING):
+                       /* just return and take the death message (which should be otw) */
+                       spin_unlock(&p->proc_lock);
+                       return;
                default:
                        // there are races that can lead to this (async death, preempt, etc)
                        panic("Weird state(%s) in %s()", procstate2str(p->state),
@@ -1325,9 +1329,14 @@ void __proc_tlbshootdown(struct proc *p, uintptr_t start, uintptr_t end)
                                active_vcoreid++; /* next loop, skip the one we just used */
                        }
                        break;
+               case (PROC_DYING):
+                       /* if it is dying, death messages are already on the way to all
+                        * cores, including ours, which will clear the TLB. */
+                       break;
                default:
                        /* will probably get this when we have the short handlers */
-                       warn("Unexpected case in %s\n", __FUNCTION__);
+                       warn("Unexpected case %s in %s", procstate2str(p->state),
+                            __FUNCTION__);
        }
 }
 
index 5db2a83..52d5ed5 100644 (file)
@@ -46,6 +46,10 @@ ssize_t core_request(struct proc *p)
        /* There are a few things broken for now if you don't have a current_tf */
        assert(current_tf);
        spin_lock(&p->proc_lock);
+       if (p->state == PROC_DYING) {
+               return -EFAIL;
+               spin_unlock(&p->proc_lock);
+       }
        /* check to see if this is a full deallocation.  for cores, it's a
         * transition from _M to _S.  Will be issues with handling this async. */
        if (!p->resources[RES_CORES].amt_wanted) {
@@ -146,6 +150,8 @@ ssize_t core_request(struct proc *p)
                                 * descheduled? */
                                panic("Not supporting RUNNABLE_S -> RUNNABLE_M yet.\n");
                                break;
+                       case (PROC_DYING):
+                               warn("Dying, core request coming from %d\n", core_id());
                        default:
                                break;
                }