M gnot/devincon.c => gnot/devincon.c +3 -3
@@ 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];
}
M gnot/sturp.c => gnot/sturp.c +1 -1
@@ 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);
M port/proc.c => port/proc.c +2 -2
@@ 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();
M port/sturp.c => port/sturp.c +1 -1
@@ 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);
M power/clock.c => power/clock.c +22 -2
@@ 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;
}
}
M power/dat.h => power/dat.h +2 -1
@@ 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 */
M power/fns.h => power/fns.h +2 -2
@@ 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);
M power/trap.c => power/trap.c +4 -3
@@ 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){