M pc/trap.c => pc/trap.c +1 -7
@@ 19,7 19,7 @@ void
intrenable(int irq, void (*f)(Ureg*, void*), void* a, int tbdf, char *name)
{
int vno;
- Vctl *v, *p;
+ Vctl *v;
v = xalloc(sizeof(Vctl));
v->isintr = 1;
@@ 36,12 36,6 @@ intrenable(int irq, void (*f)(Ureg*, void*), void* a, int tbdf, char *name)
iunlock(&vctllock);
print("intrenable: couldn't enable irq %d, tbdf 0x%uX for %s\n",
irq, tbdf, v->name);
- if(p=vctl[vno]){
- print("intrenable: irq %d is already used by", irq);
- for(; p; p=p->next)
- print(" %s", p->name);
- print("\n");
- }
xfree(v);
return;
}
M port/tod.c => port/tod.c +32 -22
@@ 22,12 22,16 @@
//
// each time f is set. f is normally set by a user level
// program writing to /dev/fastclock.
+//
+// We assume that the cpu's of a multiprocessor are synchronized.
+// This assumption needs to be questioned with each new architecture.
// frequency of the tod clock
#define TODFREQ 1000000000LL
struct {
+ ulong cnt;
Lock;
vlong multiplier; // t = off + (multiplier*ticks)>>31
vlong hz; // frequency of fast clock
@@ 103,37 107,30 @@ todget(vlong *ticksp)
else
ticks = fastticks(nil);
- /* since 64 bit ops are not atomix, we have to lock around them */
+ // since 64 bit loads are not atomic, we have to lock around them
ilock(&tod);
- diff = ticks - tod.last;
+ tod.cnt++;
+
+ // 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
+ diff = ticks - tod.last;
x = (diff * tod.multiplier) >> 31;
x = x + tod.off;
- if(m->machno == 0){
-
- // 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;
- }
- }
-
// time can't go backwards
if(x < tod.lasttime)
x = tod.lasttime;
else
tod.lasttime = x;
+
iunlock(&tod);
if(ticksp != nil)
@@ 149,12 146,25 @@ void
todfix(void)
{
vlong ticks, diff;
+ uvlong x;
ticks = fastticks(nil);
diff = ticks - tod.last;
- if(diff > tod.hz)
- todget(nil);
+ if(diff > tod.hz){
+ ilock(&tod);
+
+ // convert to epoch
+ diff = ticks - tod.last;
+ x = (diff * tod.multiplier) >> 31;
+ x = x + tod.off;
+
+ // protect against overflows
+ tod.last = ticks;
+ tod.off = x;
+
+ iunlock(&tod);
+ }
}
long