The run queues hold only runnable procs

上级 af1ff963
......@@ -39,6 +39,7 @@ idleloop(void)
if (p) {
acquire(&p->lock);
if (p->state != RUNNABLE) {
panic("Huh?");
release(&p->lock);
} else {
if (idle[mycpu()->id])
......@@ -68,8 +69,8 @@ idleloop(void)
// Process is done running for now.
// It should have changed its p->state before coming back.
mycpu()->proc = idlep;
if (p->state != RUNNABLE)
delrun(p);
if (p->state == RUNNABLE)
addrun(p);
release(&p->lock);
}
} else {
......
......@@ -74,6 +74,7 @@ steal(void)
if (p->state == RUNNABLE && !p->cpu_pin &&
p->curcycles != 0 && p->curcycles > VICTIMAGE)
{
STAILQ_REMOVE(&q->q, p, proc, runqlink);
steal = p;
break;
}
......@@ -85,7 +86,7 @@ steal(void)
if (steal->state == RUNNABLE && !steal->cpu_pin &&
steal->curcycles != 0 && steal->curcycles > VICTIMAGE)
{
delrun(steal);
//delrun(steal);
steal->curcycles = 0;
steal->cpuid = mycpu()->id;
addrun(steal);
......@@ -93,6 +94,8 @@ steal(void)
r = 1;
break;
}
if (steal->state == RUNNABLE)
addrun(steal);
release(&steal->lock);
}
}
......@@ -112,10 +115,8 @@ schednext(void)
q = &runq[cpunum()];
acquire(&q->lock);
p = STAILQ_LAST(&q->q, proc, runqlink);
if (p) {
if (p)
STAILQ_REMOVE(&q->q, p, proc, runqlink);
STAILQ_INSERT_HEAD(&q->q, p, runqlink);
}
release(&q->lock);
popcli();
return p;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论