M port/portdat.h => port/portdat.h +1 -0
@@ 502,6 502,7 @@ enum
Nrq = 20, /* number of scheduler priority levels */
PriNormal = 10, /* base priority for normal processes */
+ PriKproc = 13, /* base priority for kernel processes */
PriRoot = 13, /* base priority for root processes */
};
M port/proc.c => port/proc.c +16 -4
@@ 137,11 137,22 @@ ready(Proc *p)
s = splhi();
- if(p->state == Running)
+ /* history counts */
+ if(p->state == Running){
p->rt++;
- pri = p->basepri - (((p->art + p->rt)>>1)/Squantum);
+ pri = ((p->art + (p->rt<<1))>>2)/Squantum;
+ } else {
+ p->art = (p->art + (p->rt<<1))>>2;
+ p->rt = 0;
+ pri = p->art/Squantum;
+ }
+ pri = p->basepri - pri;
if(pri < 0)
pri = 0;
+
+ /* the only intersection between the classes is at PriNormal */
+ if(pri < PriNormal && p->basepri > PriNormal)
+ pri = PriNormal;
p->priority = pri;
rq = &runq[p->priority];
@@ 364,8 375,6 @@ sleep1(Rendez *r, int (*f)(void*), void *arg)
dumpstack();
}
up->state = Wakeme;
- up->art = (up->art + up->rt)>>1;
- up->rt = 0;
r->p = up;
unlock(r);
}
@@ 812,6 821,9 @@ kproc(char *name, void (*func)(void *), void *arg)
p->ureg = 0;
p->dbgreg = 0;
+ p->basepri = PriKproc;
+ p->priority = p->basepri;
+
kprocchild(p, func, arg);
strcpy(p->user, eve);