sgi: cleanup timer code
- no need to splhi() in timerset, always called with interrupts off. - make timerset always update the period (next == 0) - remove period update in fastticks(), simplify delta calculation.
This commit is contained in:
parent
a2eafd2cb0
commit
6cb359cc00
1 changed files with 10 additions and 16 deletions
|
@ -83,7 +83,8 @@ clockinit(void)
|
||||||
|
|
||||||
m->maxperiod = Basetickfreq / HZ;
|
m->maxperiod = Basetickfreq / HZ;
|
||||||
m->minperiod = Basetickfreq / (100*HZ);
|
m->minperiod = Basetickfreq / (100*HZ);
|
||||||
wrcompare(rdcount()+m->maxperiod);
|
m->lastcount = rdcount();
|
||||||
|
wrcompare(m->lastcount+m->maxperiod);
|
||||||
|
|
||||||
intron(INTR7);
|
intron(INTR7);
|
||||||
}
|
}
|
||||||
|
@ -128,12 +129,7 @@ fastticks(uvlong *hz)
|
||||||
/* avoid reentry on interrupt or trap, to prevent recursion */
|
/* avoid reentry on interrupt or trap, to prevent recursion */
|
||||||
x = splhi();
|
x = splhi();
|
||||||
count = rdcount();
|
count = rdcount();
|
||||||
if(rdcompare() - count > m->maxperiod)
|
delta = count - m->lastcount;
|
||||||
wrcompare(count+m->maxperiod);
|
|
||||||
if (count < m->lastcount) /* wrapped around? */
|
|
||||||
delta = count + ((1ull<<32) - m->lastcount);
|
|
||||||
else
|
|
||||||
delta = count - m->lastcount;
|
|
||||||
m->lastcount = count;
|
m->lastcount = count;
|
||||||
m->fastticks += delta;
|
m->fastticks += delta;
|
||||||
splx(x);
|
splx(x);
|
||||||
|
@ -150,18 +146,16 @@ perfticks(void)
|
||||||
void
|
void
|
||||||
timerset(Tval next)
|
timerset(Tval next)
|
||||||
{
|
{
|
||||||
int x;
|
|
||||||
long period;
|
long period;
|
||||||
|
|
||||||
if(next == 0)
|
if(next == 0)
|
||||||
return;
|
|
||||||
x = splhi(); /* don't let us get scheduled */
|
|
||||||
period = next - fastticks(nil);
|
|
||||||
if(period > m->maxperiod - m->minperiod)
|
|
||||||
period = m->maxperiod;
|
period = m->maxperiod;
|
||||||
else if(period < m->minperiod)
|
else {
|
||||||
period = m->minperiod;
|
period = next - fastticks(nil);
|
||||||
|
if(period > m->maxperiod)
|
||||||
|
period = m->maxperiod;
|
||||||
|
else if(period < m->minperiod)
|
||||||
|
period = m->minperiod;
|
||||||
|
}
|
||||||
wrcompare(rdcount()+period);
|
wrcompare(rdcount()+period);
|
||||||
splx(x);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue