diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-01-22 20:39:14 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-01-22 20:39:14 +0100 |
commit | 6cb359cc00bdc8204b011db46b8746c446f2c4de (patch) | |
tree | 8d794526ab0f7cb7e49d0bd4a05b4960e937b0d8 /sys/src/9/sgi | |
parent | a2eafd2cb0d6206ddaa846d50c320a309a17f05e (diff) |
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.
Diffstat (limited to 'sys/src/9/sgi')
-rw-r--r-- | sys/src/9/sgi/clock.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/sys/src/9/sgi/clock.c b/sys/src/9/sgi/clock.c index 8a026520a..0355e66f5 100644 --- a/sys/src/9/sgi/clock.c +++ b/sys/src/9/sgi/clock.c @@ -83,7 +83,8 @@ clockinit(void) m->maxperiod = Basetickfreq / HZ; m->minperiod = Basetickfreq / (100*HZ); - wrcompare(rdcount()+m->maxperiod); + m->lastcount = rdcount(); + wrcompare(m->lastcount+m->maxperiod); intron(INTR7); } @@ -128,12 +129,7 @@ fastticks(uvlong *hz) /* avoid reentry on interrupt or trap, to prevent recursion */ x = splhi(); count = rdcount(); - if(rdcompare() - count > m->maxperiod) - wrcompare(count+m->maxperiod); - if (count < m->lastcount) /* wrapped around? */ - delta = count + ((1ull<<32) - m->lastcount); - else - delta = count - m->lastcount; + delta = count - m->lastcount; m->lastcount = count; m->fastticks += delta; splx(x); @@ -150,18 +146,16 @@ perfticks(void) void timerset(Tval next) { - int x; long period; 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; - else if(period < m->minperiod) - period = m->minperiod; + else { + period = next - fastticks(nil); + if(period > m->maxperiod) + period = m->maxperiod; + else if(period < m->minperiod) + period = m->minperiod; + } wrcompare(rdcount()+period); - splx(x); - } |