~kris/9p

9hist

a4ee70ffec18b568a207d42790ca734356d21dde — David du Colombier 32 years ago a591740
Plan 9 from Bell Labs 1994-09-17
2 files changed, 15 insertions(+), 6 deletions(-)

M port/portdat.h
M port/proc.c
M port/portdat.h => port/portdat.h +2 -0
@@ 585,6 585,8 @@ struct Proc
	Mach	*mp;		/* machine this process last ran on */
	ulong	priority;	/* priority level */
	ulong	basepri;	/* base priority level */
	ulong	rt;		/* # ticks used since last blocked */
	ulong	art;		/* avg # ticks used since last blocked */
	ulong	movetime;	/* last time process switched processors */
	ulong	readyticks;	/* time process went ready */


M port/proc.c => port/proc.c +13 -6
@@ 124,19 124,24 @@ anyhigher(void)
	return nrdy && x >= up->priority;
}

enum
{
	Squantum = (HZ+Nrq-1)/Nrq,
};

void
ready(Proc *p)
{
	int s;
	int s, pri;
	Schedq *rq;

	s = splhi();

	if(p->state == Running){
		if(p->priority > 0)
			p->priority--;
	} else
		p->priority = p->basepri;
	if(p->state == Running)
		p->rt++;
	pri = p->basepri - (((p->art + p->rt)>>1)/Squantum);
	if(pri < 0)
		pri = 0;
	rq = &runq[p->priority];

	lock(runq);


@@ 330,6 335,8 @@ 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);
}