static void rebalance(void) { int pri, npri, t, x; Schedq *rq; Proc *p; t = m->ticks; if(t - balancetime < HZ) return; balancetime = t; for(pri=0, rq=runq; pri<Npriq; pri++, rq++){ another: p = rq->head; if(p == nil) continue; if(p->mp != MACHP(m->machno)) continue; if(pri == p->basepri) continue; updatecpu(p); npri = reprioritize(p); if(npri != pri){ x = splhi(); p = dequeueproc(rq, p); if(p != nil) queueproc(&runq[npri], p); splx(x); goto another; } } }
/* * ready(p) picks a new priority for a process and sticks it in the * runq for that priority. */ void ready(Proc *p) { int s, pri; Schedq *rq; void (*pt)(Proc*, int, vlong); if(p->state == Ready){ print("double ready %s %lud pc %p\n", p->text, p->pid, getcallerpc(&p)); return; } s = splhi(); if(edfready(p)){ splx(s); return; } if(up != p && (p->wired == nil || p->wired == MACHP(m->machno))) m->readied = p; /* group scheduling */ updatecpu(p); pri = reprioritize(p); p->priority = pri; rq = &runq[pri]; p->state = Ready; queueproc(rq, p); pt = proctrace; if(pt != nil) pt(p, SReady, 0); splx(s); }
/* * recalculate priorities once a second. We need to do this * since priorities will otherwise only be recalculated when * the running process blocks. */ static void rebalance(void) { Mach *m = machp(); Mpl pl; int pri, npri, t; Schedq *rq; Proc *p; t = m->ticks; if(t - run.balancetime < HZ) return; run.balancetime = t; for(pri=0, rq=run.runq; pri<Npriq; pri++, rq++){ another: p = rq->head; if(p == nil) continue; if(p->mp != sys->machptr[m->machno]) //MACHP(m->machno) continue; if(pri == p->basepri) continue; updatecpu(p); npri = reprioritize(p); if(npri != pri){ pl = splhi(); p = dequeueproc(&run, rq, p); if(p) queueproc(&run, &run.runq[npri], p, 0); splx(pl); goto another; } } }
static void schedready(Sched *sch, Proc *p, int locked) { Mpl pl; int pri; Schedq *rq; pl = splhi(); if(edfready(p)){ splx(pl); return; } /* if(m->externup != p) m->readied = p; *//* group scheduling, will be removed */ updatecpu(p); pri = reprioritize(p); p->priority = pri; rq = &sch->runq[pri]; p->state = Ready; queueproc(sch, rq, p, locked); if(p->trace) proctrace(p, SReady, 0); splx(pl); }
/* * ready(p) picks a new priority for a process and sticks it in the * runq for that priority. */ void ready(Proc *p) { int s, pri; Schedq *rq; void (*pt)(Proc*, int, vlong); s = splhi(); if(edfready(p)){ splx(s); return; } if(up != p) m->readied = p; /* group scheduling */ updatecpu(p); pri = reprioritize(p); p->priority = pri; rq = &runq[pri]; p->state = Ready; queueproc(rq, p); pt = proctrace; if(pt) pt(p, SReady, 0); splx(s); }
static void schedready(Sched *sch, Proc *p, int locked) { Mpl pl; int pri; Schedq *rq; pl = splhi(); if(edfready(p)){ splx(pl); return; } updatecpu(p); pri = reprioritize(p); p->priority = pri; rq = &sch->runq[pri]; p->state = Ready; queueproc(sch, rq, p, locked); if(p->trace) proctrace(p, SReady, 0); splx(pl); }