From b91c47e11c5ffe7dca63ce430006682072a6e095 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 31 Jul 1990 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1990-07-31 --- gnot/devincon.c | 6 +++--- gnot/sturp.c | 2 +- port/proc.c | 4 ++-- port/sturp.c | 2 +- power/clock.c | 24 ++++++++++++++++++++++-- power/dat.h | 3 ++- power/fns.h | 4 ++-- power/trap.c | 7 ++++--- 8 files changed, 37 insertions(+), 15 deletions(-) diff --git a/gnot/devincon.c b/gnot/devincon.c index 9da2e4a17583408b6a0ad5df3550cce581bd13f1..b8cf9b0c8d6d8c4414eb3c1f3e2b853a3772435f 100644 --- a/gnot/devincon.c +++ b/gnot/devincon.c @@ -683,14 +683,14 @@ nextin(Incon *ip, unsigned int c) bp->base[1] = ip->chan>>8; bp->base[2] = c; if(incondebug) - print("<-(%d)%uo %d\n", ip->chan, c, bp->wptr-bp->rptr)-3; + print("<-(%d)%uo %d\n", ip->chan, c, bp->wptr-bp->rptr); - next = (ip->wi+3)%Nin; + next = (ip->wi+1)%Nin; if(next == ip->ri){ bp->wptr = bp->base+3; return bp; } - ip->wi = (ip->wi+1)%Nin; + ip->wi = next; return ip->inb[ip->wi]; } diff --git a/gnot/sturp.c b/gnot/sturp.c index 929461944bf8e7a86514ce7601e185e79b26bae6..aaca87531cc68261dde93fa24ebdf95ee0c89643 100644 --- a/gnot/sturp.c +++ b/gnot/sturp.c @@ -988,7 +988,7 @@ urptimer(Alarm *a) for(up = urp, last = &urp[conf.nurp]; up < last; up++){ if(up->state==0) continue; - if(up->unacked!=up->next && NOW>up->timer){ + if((up->unacked!=up->next || (up->state&INITING)) && NOW>up->timer){ q = up->rq; if(q) wakeup(&q->r); diff --git a/port/proc.c b/port/proc.c index a68f9eb1f4c72ce8f6b0c082a91ca4a6a7707f11..ede1322f36f5eeebfb5b46de07e3c8712d140b62 100644 --- a/port/proc.c +++ b/port/proc.c @@ -77,7 +77,7 @@ sched(void) { Proc *p; ulong tlbvirt, tlbphys; - void (*f)(ulong); + void (*f)(ulong, ulong); if(u){ splhi(); @@ -93,7 +93,7 @@ sched(void) } if(f = m->intr){ /* assign = */ m->intr = 0; - (*f)(m->cause); + (*f)(m->cause, m->pc); } spllo(); p = runproc(); diff --git a/port/sturp.c b/port/sturp.c index 929461944bf8e7a86514ce7601e185e79b26bae6..aaca87531cc68261dde93fa24ebdf95ee0c89643 100644 --- a/port/sturp.c +++ b/port/sturp.c @@ -988,7 +988,7 @@ urptimer(Alarm *a) for(up = urp, last = &urp[conf.nurp]; up < last; up++){ if(up->state==0) continue; - if(up->unacked!=up->next && NOW>up->timer){ + if((up->unacked!=up->next || (up->state&INITING)) && NOW>up->timer){ q = up->rq; if(q) wakeup(&q->r); diff --git a/power/clock.c b/power/clock.c index ae2b78a5dcad3af6d268205021086be6b266b124..a5f3d37e4ad4a9e7b76165973da9db67e97f00fb 100644 --- a/power/clock.c +++ b/power/clock.c @@ -107,13 +107,23 @@ struct Timer{ junk3[3]; }; + #define TIME0 (36*MS2HZ/10) -#define TIME1 0xFFFFFFFF /* later, make this a profiling clock */ +#define TIME1 0xFFFFFFFF /* profiling disabled */ #define TIME2 1024 #define CTR(x) ((x)<<6) /* which counter x */ #define SET16 0x30 /* lsbyte then msbyte */ #define MODE2 0x04 /* interval timer */ + +#define PROFILING +#ifdef PROFILING +#undef TIME1 +#define TIME1 211 /* profiling clock; prime; about 10ms per tick */ +#define NPROF 50000 +ulong profcnt[MAXMACH*NPROF]; +#endif + void clockinit(void) { @@ -135,9 +145,11 @@ clockinit(void) m->ticks = 0; } + + #define NA 10 void -clock(ulong n) +clock(ulong n, ulong pc) { int i, na; Alarm *a; @@ -192,7 +204,15 @@ clock(ulong n) return; } if(n & INTR4){ + extern ulong start; + i = *CLRTIM1; +#ifdef PROFILING + pc -= (ulong)&start; + pc /= sizeof(ulong); + if(pc < NPROF) + profcnt[m->machno*NPROF+pc]++; +#endif return; } } diff --git a/power/dat.h b/power/dat.h index 09f20b5aa62a7bb3f7fa0402ac85f7efe13a34fd..7cccd9b539760cf2b8c7901afdeca9472db6fd91 100644 --- a/power/dat.h +++ b/power/dat.h @@ -199,9 +199,10 @@ struct Mach Label sched; /* scheduler wakeup */ Lock alarmlock; /* access to alarm list */ void *alarm; /* alarms bound to this clock */ - void (*intr)(ulong); /* pending interrupt */ + void (*intr)(ulong, ulong); /* pending interrupt */ Proc *intrp; /* process that was interrupted */ ulong cause; /* arg to intr */ + ulong pc; /* pc that was interrupted */ char pidhere[NTLBPID]; /* is this pid possibly in this mmu? */ int lastpid; /* last pid allocated on this machine */ Proc *pidproc[NTLBPID]; /* process that owns this tlbpid on this mach */ diff --git a/power/fns.h b/power/fns.h index 4a9554429ce39ebf96d3cc6bebdbc9a18320edde..812f5f4e023dd3e7eb76bc153bffeb9a070c8b78 100644 --- a/power/fns.h +++ b/power/fns.h @@ -9,7 +9,7 @@ int canqlock(QLock*); void chaninit(void); void chandevreset(void); void chandevinit(void); -void clock(ulong); +void clock(ulong, ulong); void clockinit(void); Chan *clone(Chan*, Chan*); void close(Chan*); @@ -75,7 +75,7 @@ void *ialloc(ulong, int); void icflush(void *, int); int incref(Ref*); void insert(List**, List*, List*); -void intr(ulong); +void intr(ulong, ulong); void io2init(void); void isdir(Chan*); void kbdchar(int); diff --git a/power/trap.c b/power/trap.c index de4a3f582a5914aff8e55a058f3d2ab3408a3784..77cad73217f6c1828fff025347541a4220affdcd 100644 --- a/power/trap.c +++ b/power/trap.c @@ -101,11 +101,12 @@ trap(Ureg *ur) } m->intr = intr; m->cause = ur->cause; + m->pc = ur->pc; if(ur->cause & INTR2) m->intrp = u->p; sched(); }else - intr(ur->cause); + intr(ur->cause, ur->pc); break; case CTLBM: @@ -179,14 +180,14 @@ trap(Ureg *ur) } void -intr(ulong cause) +intr(ulong cause, ulong pc) { int i, pend; long v; cause &= INTR5|INTR4|INTR3|INTR2|INTR1; if(cause & (INTR2|INTR4)){ - clock(cause); + clock(cause, pc); cause &= ~(INTR2|INTR4); } if(cause & INTR1){