提交 b025a666 创建 作者: Frans Kaashoek's avatar Frans Kaashoek

don't remove from runq too early

上级 38f41095
...@@ -280,7 +280,7 @@ exit(void) ...@@ -280,7 +280,7 @@ exit(void)
acquire(&proc->lock); acquire(&proc->lock);
delrun1(runq, proc); // XXX get lock on runq delrun(proc);
// Jump into the scheduler, never to return. // Jump into the scheduler, never to return.
proc->state = ZOMBIE; proc->state = ZOMBIE;
...@@ -489,14 +489,17 @@ kill(int pid) ...@@ -489,14 +489,17 @@ kill(int pid)
for (c = 0; c < NCPU; c++) { for (c = 0; c < NCPU; c++) {
acquire(&ptables[c].lock); acquire(&ptables[c].lock);
for(p = ptables[c].proc; p < &ptables[c].proc[NPROC]; p++){ for(p = ptables[c].proc; p < &ptables[c].proc[NPROC]; p++){
acquire(&p->lock);
if(p->pid == pid){ if(p->pid == pid){
p->killed = 1; p->killed = 1;
// Wake process from sleep if necessary. // Wake process from sleep if necessary.
if(p->state == SLEEPING) if(p->state == SLEEPING)
addrun1(&runqs[c], p); addrun1(&runqs[c], p);
acquire(&p->lock);
release(&ptables[c].lock); release(&ptables[c].lock);
return 0; return 0;
} }
acquire(&p->lock);
} }
release(&ptables[c].lock); release(&ptables[c].lock);
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论