From 409b865291e53eb3a52f2f39867fedea3be9aab0 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 20 Sep 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-09-20 --- port/portdat.h | 1 + port/proc.c | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/port/portdat.h b/port/portdat.h index 664d9590035dbc4e66881e45577cc2862170d1dd..d1f953ed0087843e2311bac2bcd47ef9d880f6e1 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -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 */ }; diff --git a/port/proc.c b/port/proc.c index 8d934f71c875ecaa3199ef71c67c630b53a986b1..5b528c4b483faa87d75882dca22626a1c9d5b0cb 100644 --- a/port/proc.c +++ b/port/proc.c @@ -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);