Remove dead code in sched.c

上级 eca599b3
...@@ -130,107 +130,3 @@ initsched(void) ...@@ -130,107 +130,3 @@ initsched(void)
STAILQ_INIT(&runq[i].q); STAILQ_INIT(&runq[i].q);
} }
} }
#if 0
// XXX(sbw) This code is broken. It essentially implements "LIFO"
// scheduling, which leads to starvation and deadlock (in userspace).
struct ns *nsrunq __mpalign__;
// Mark a process RUNNABLE and add it to the runq
// of its cpu. Caller must hold p->lock so that
// some other core doesn't start running the
// process before the caller has finished setting
// the process up, and to cope with racing callers
// e.g. two wakeups on same process. and to
// allow atomic addrun(); sched();
void
addrun(struct proc *p)
{
#if SPINLOCK_DEBUG
if(!holding(&p->lock))
panic("addrun no p->lock");
#endif
if (p->on_runq >= 0)
panic("addrun on runq already");
ns_insert(nsrunq, KI(p->cpuid), p);
p->on_runq = p->cpuid;
}
void
delrun(struct proc *p)
{
#if SPINLOCK_DEBUG
if(!holding(&p->lock))
panic("delrun no p->lock");
#endif
if (p->on_runq < 0)
panic("delrun not on runq");
if (ns_remove(nsrunq, KI(p->on_runq), p) == 0)
panic("delrun: ns_remove");
p->on_runq = -1;
}
static void *
steal_cb(void *vk, void *v, void *arg)
{
struct proc *p = v;
acquire(&p->lock);
if (p->state != RUNNABLE || p->cpuid == mycpu()->id || p->cpu_pin) {
release(&p->lock);
return 0;
}
if (p->curcycles == 0 || p->curcycles > VICTIMAGE) {
if (sched_debug)
cprintf("cpu%d: steal %d (cycles=%d) from %d\n",
mycpu()->id, p->pid, (int)p->curcycles, p->cpuid);
delrun(p);
p->curcycles = 0;
p->cpuid = mycpu()->id;
addrun(p);
release(&p->lock);
return p;
}
release(&p->lock);
return 0;
}
int
steal(void)
{
void *stole = ns_enumerate(nsrunq, steal_cb, 0);
return stole ? 1 : 0;
}
static void *
choose_runnable(void *pp, void *arg)
{
struct proc *head = pp;
if (head->state == RUNNABLE)
return head;
return 0;
}
struct proc *
schednext(void)
{
// XXX(sbw) Yikes! If two processes are runnable on the same
// CPU this will always return to process addrun inserted last
// into the ns.
return ns_enumerate_key(nsrunq, KI(mycpu()->id), choose_runnable, 0);
}
void
initsched(void)
{
nsrunq = nsalloc(1);
if (nsrunq == 0)
panic("pinit runq");
}
#endif
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论