From c4b47bcf34d2c414a203ee7bb3b596b3da863fd5 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 10 Aug 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-08-10 --- alphapc/dat.h | 1 + carrera/dat.h | 1 + ip/tcp.c | 8 +++++--- mpc/dat.h | 1 + pc/dat.h | 1 + port/lib.h | 1 + port/print.c | 1 - port/taslock.c | 4 ++++ port/tod.c | 37 ++++++++++++++++++++----------------- 9 files changed, 34 insertions(+), 21 deletions(-) diff --git a/alphapc/dat.h b/alphapc/dat.h index 166d03eeab19d3c115f37a8fb0581c66f2ff4adf..aed58a6686e8d7eafd7384413636ea149956e726 100644 --- a/alphapc/dat.h +++ b/alphapc/dat.h @@ -33,6 +33,7 @@ struct Lock Proc *p; ulong pid; ushort isilock; + ulong glare; }; struct Label diff --git a/carrera/dat.h b/carrera/dat.h index d14b4ee3f10777abba5e9c23a80e738ceb197249..a49a43154591c9dfbd2a97bc68f2e232dbe47d7b 100644 --- a/carrera/dat.h +++ b/carrera/dat.h @@ -29,6 +29,7 @@ struct Lock ulong pc; Proc *p; ushort isilock; + ulong glare; }; struct Label diff --git a/ip/tcp.c b/ip/tcp.c index 04fcddfb6e8c9d60e18d6e500a6aad6d1a5d4b49..7b9b839921361328b0c8ed1cb405c87c51e32231 100644 --- a/ip/tcp.c +++ b/ip/tcp.c @@ -1971,7 +1971,7 @@ void addreseq(Tcpctl *tcb, Tcp *seg, Block *bp, ushort length) { Reseq *rp, *rp1; - int i; + int i, x; rp = malloc(sizeof(Reseq)); if(rp == nil){ @@ -1991,9 +1991,9 @@ addreseq(Tcpctl *tcb, Tcp *seg, Block *bp, ushort length) return; } + length = 0; for(i = 0;; i++) { - if(i > 100) - print("very long tcp resequence queue\n"); + length += rp1->length; if(rp1->next == nil || seq_lt(seg->seq, rp1->next->seg.seq)) { rp->next = rp1->next; rp1->next = rp; @@ -2001,6 +2001,8 @@ addreseq(Tcpctl *tcb, Tcp *seg, Block *bp, ushort length) } rp1 = rp1->next; } + if(i > 100) + print("very long tcp resequence queue: %d\n", length); } void diff --git a/mpc/dat.h b/mpc/dat.h index 8512b4616dce1d8e4ddea76eb2298b6d298e13de..e10a5675887b67c0d2b619ff165353913b45eec7 100644 --- a/mpc/dat.h +++ b/mpc/dat.h @@ -30,6 +30,7 @@ struct Lock ulong sr; Proc *p; ushort isilock; + ulong glare; }; struct Label diff --git a/pc/dat.h b/pc/dat.h index 1cfc12ba3531be282a435b23c07d69b57c2425a9..8e757e16cf1933b3a1fdb774f2e09f526fdaec70 100644 --- a/pc/dat.h +++ b/pc/dat.h @@ -28,6 +28,7 @@ struct Lock ulong pc; Proc *p; ushort isilock; + ulong glare; }; struct Label diff --git a/port/lib.h b/port/lib.h index a904fc7614c153507f747c8d1d019c1420b4f0f9..c82d83a5f3aa3dd64705c31bd9e0722e583bb192 100644 --- a/port/lib.h +++ b/port/lib.h @@ -16,6 +16,7 @@ extern void *memchr(void*, int, long); */ extern char *strcat(char*, char*); extern char *strchr(char*, char); +extern char *strrchr(char*, char); extern int strcmp(char*, char*); extern char *strcpy(char*, char*); extern char *strncat(char*, char*, long); diff --git a/port/print.c b/port/print.c index 2292913245bbb72468a4ab65952a0228c731acce..ad1ab994d05eb61c305b4eb4e9fdfb005355acb1 100644 --- a/port/print.c +++ b/port/print.c @@ -3,7 +3,6 @@ enum { - SIZE = 1024, IDIGIT = 30, MAXCONV = 40, FDIGIT = 30, diff --git a/port/taslock.c b/port/taslock.c index 042582969ebec1a819b57f7487ec8342e264055e..1c964cb3261cda77b29c0787c4ede9e403d97e8c 100644 --- a/port/taslock.c +++ b/port/taslock.c @@ -102,6 +102,10 @@ lockstats.locks++; } lockstats.glare++; +if(l->glare++ > 10000){ +print("glare %lux\n", l); +l->glare = 0; +} cansched = up != nil && up->state == Running; if(cansched){ oldpri = up->priority; diff --git a/port/tod.c b/port/tod.c index 7cdf94134515bb86acb53bd54e9980806a904762..9b7b1b4bee3a7032a8ced2938ab050db7b91cf42 100644 --- a/port/tod.c +++ b/port/tod.c @@ -98,42 +98,45 @@ todget(vlong *ticksp) vlong ticks, diff; ulong t; - ilock(&tod); - if(tod.hz == 0) ticks = fastticks((uvlong*)&tod.hz); else ticks = fastticks(nil); diff = ticks - tod.last; - // add in correction - if(tod.sstart != tod.send){ - t = MACHP(0)->ticks; - if(t >= tod.send) - t = tod.send; - tod.off = tod.off + tod.delta*(t - tod.sstart); - tod.sstart = t; - } - // convert to epoch x = (diff * tod.multiplier) >> 31; x = x + tod.off; - // protect against overflows - if(diff > tod.hz){ - tod.last = ticks; - tod.off = x; + if(m->machno == 0){ + ilock(&tod); + + // add in correction + if(tod.sstart != tod.send){ + t = MACHP(0)->ticks; + if(t >= tod.send) + t = tod.send; + tod.off = tod.off + tod.delta*(t - tod.sstart); + tod.sstart = t; + } + + // protect against overflows + if(diff > tod.hz){ + tod.last = ticks; + tod.off = x; + } + iunlock(&tod); } // time can't go backwards if(x < tod.lasttime) x = tod.lasttime; - tod.lasttime = x; + else + tod.lasttime = x; if(ticksp != nil) *ticksp = ticks; - iunlock(&tod); return x; }