~kris/9p

9hist

c82a4de14fee442f72fd49b064c330db9733594a — David du Colombier 27 years ago fbdabd0
Plan 9 from Bell Labs 1999-03-27
9 files changed, 41 insertions(+), 13 deletions(-)

M carrera/clock.c
M carrera/fns.h
M carrera/l.s
M carrera/mem.h
M carrera/screen.c
M ip/tcp.c
M mpc/fns.h
M pc/fns.h
M port/proc.c
M carrera/clock.c => carrera/clock.c +29 -8
@@ 51,6 51,8 @@ delay(int l)
			;
}

ulong lastcmp;

void
clockinit(void)
{


@@ 72,18 74,16 @@ clockinit(void)

	incr = (m->speed*1000000)/HZ;
	fasthz = m->speed*1000000;
	wrcompare(rdcount()+incr);
	wrcompare(lastcmp = rdcount()+incr);
}

uvlong
updatefastclock(ulong count)
{
	vlong delta;
	ulong delta;

	/* keep track of higher precision time */
	delta = count - m->lastcyclecount;
	if(delta < 0)
		delta += 0x100000000LL;
	m->lastcyclecount = count;
	m->fastclock += delta;



@@ 97,7 97,7 @@ clock(Ureg *ur)
	ulong count;

	count = rdcount();
	wrcompare(count+incr);
	wrcompare(lastcmp = count+incr);
	updatefastclock(count);

	m->ticks++;


@@ 136,14 136,14 @@ clock(Ureg *ur)
	if(up == 0 || up->state != Running)
		return;

	if(anyready())
		sched();

	/* user profiling clock */
	if(ur->status & KUSER) {
		(*(ulong*)(USTKTOP-BY2WD)) += TK2MS(1);
		segclock(ur->pc);
	}

	if(anyready())
		sched();
}

vlong


@@ 161,3 161,24 @@ fastticks(uvlong *hz)

	return (vlong)cyclecount;
}

ulong timewarp;

void
idlehands(void)
{
	ulong cnt, cmp, d;
	int x;

	x = splhi();
	cnt = rdcount();
	cmp = rdcompare();
	cnt -= 100;		/* to cover for time from splhi to rdcount */
	d = cmp - cnt;
	if(d > incr+100){
		wrcompare(lastcmp = cnt+incr);
		timewarp++;
//		print("%lud %lud %d %lux\n", cnt, cmp, cnt-cmp, d);
	}
	splx(x);
}

M carrera/fns.h => carrera/fns.h +2 -0
@@ 25,6 25,7 @@ void		gettlb(int, ulong*);
int		gettlbp(ulong, ulong*);
ulong		gettlbvirt(int);
void		icflush(void *, ulong);
void		idlehands(void);
void		intr(Ureg*);
void		ioinit(int);
int		iprint(char*, ...);


@@ 48,6 49,7 @@ Softtlb*	putstlb(ulong, ulong);
int		puttlb(ulong, ulong, ulong);
void		puttlbx(int, ulong, ulong, ulong, int);
void		rdbginit(void);
ulong		rdcompare(void);
ulong		rdcount(void);
ulong*		reg(Ureg*, int);
void		restfpregs(FPsave*, ulong);

M carrera/l.s => carrera/l.s +5 -0
@@ 797,3 797,8 @@ TEXT	rdcount(SB), $0
TEXT	wrcompare(SB), $0
	MOVW	R1, M(COMPARE)
	RET

TEXT	rdcompare(SB), $0
	MOVW	M(COMPARE), R1
	NOP
	RET

M carrera/mem.h => carrera/mem.h +1 -1
@@ 22,7 22,7 @@
/*
 * Time
 */
#define	HZ		1000			/* clock frequency */
#define	HZ		250			/* clock frequency */
#define	MS2HZ		(1000/HZ)		/* millisec per clock tick */
#define	TK2SEC(t)	((t)/HZ)		/* ticks to seconds */
#define	TK2MS(t)	((t)*MS2HZ)		/* ticks to milliseconds */

M carrera/screen.c => carrera/screen.c +0 -3
@@ 586,7 586,6 @@ cursoron(int dolock)
{
	Dac *d;
	Point p;
	int s;

	p = mousexy();



@@ 594,7 593,6 @@ cursoron(int dolock)

	if(dolock)
		lock(&cursor);
	s = splhi();

	p.x += 296;		/* adjusted by experiment */
	p.y += 9;		/* adjusted by experiment */


@@ 605,7 603,6 @@ cursoron(int dolock)
	d->cr2 = p.y&0xFF;
	d->cr2 = (p.y>>8)&0xF;

	splx(s);
	if(dolock)
		unlock(&cursor);
	return 0;

M ip/tcp.c => ip/tcp.c +1 -1
@@ 454,7 454,7 @@ static void
tcpcreate(Conv *c)
{
	c->rq = qopen(QMAX, 0, tcpacktimer, c);
	c->wq = qopen(QMAX, 0, 0, 0);
	c->wq = qopen(2*QMAX, 0, 0, 0);
}

void

M mpc/fns.h => mpc/fns.h +1 -0
@@ 41,6 41,7 @@ ulong	gettbu(void);
void	gotopc(ulong);
void	icflush(void*, ulong);
void	idle(void);
#define	idlehands()			/* nothing to do in the runproc */
int	iprint(char*, ...);
void	intr(Ureg*);
void	intrenable(int, void (*)(Ureg*, void*), void*, int);

M pc/fns.h => pc/fns.h +1 -0
@@ 40,6 40,7 @@ uvlong	i8253read(uvlong*);
void	i8259init(void);
int	i8259enable(Vctl*);
void	idle(void);
#define	idlehands()			/* nothing to do in the runproc */
int	inb(int);
void	insb(int, void*, int);
ushort	ins(int);

M port/proc.c => port/proc.c +1 -0
@@ 200,6 200,7 @@ loop:
	 */
	spllo();
	for(;;){
		idlehands();
		if((++(m->fairness) & 3) == 0){
			/*
			 *  once in a while, run process that's been waiting longest