| plan 9 kernel history: overview | file list | diff list |
1992/0811/ss/clock.c (diff list | history)
| ss/clock.c on 1990/1223 | ||
| 1990/1223 | #include "u.h" | |
| 1992/0321 | #include "../port/lib.h" | |
| 1990/1223 | #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" #include "ureg.h" void delay(int ms) { int i; | |
| 1991/1115 | ms *= 3000; /* experimentally determined */ | |
| 1990/1223 | for(i=0; i<ms; i++) ; } | |
| 1990/1227 | typedef struct Ctr Ctr; struct Ctr { ulong ctr0; ulong lim0; ulong ctr1; ulong lim1; }; Ctr *ctr; | |
| 1990/1223 | void | |
| 1990/1227 | clockinit(void) { KMap *k; k = kmappa(CLOCK, PTENOCACHE|PTEIO); ctr = (Ctr*)k->va; ctr->lim1 = (CLOCKFREQ/HZ)<<10; } void | |
| 1990/1223 | clock(Ureg *ur) { Proc *p; | |
| 1991/1114 | ulong i, nrun = 0; | |
| 1990/1223 | ||
| 1990/1227 | i = ctr->lim1; /* clear interrupt */ USED(i); | |
| 1990/1223 | m->ticks++; p = m->proc; if(p){ | |
| 1991/1113 | nrun = 1; | |
| 1990/1223 | p->pc = ur->pc; if (p->state==Running) p->time[p->insyscall]++; } | |
| 1991/1113 | nrun = (nrdy+nrun)*1000; MACHP(0)->load = (MACHP(0)->load*19+nrun)/20; | |
| 1990/1223 | checkalarms(); kbdclock(); mouseclock(); | |
| 1991/1003 | sccclock(); | |
| 1991/1006 | kproftimer(ur->pc); | |
| 1992/0807 | if(m->fpunsafe) return; | |
| 1990/1227 | if((ur->psr&SPL(0xF))==0 && p && p->state==Running){ | |
| 1991/0821 | if(anyready()){ if(p->hasspin) p->hasspin = 0; else sched(); } | |
| 1992/0811 | if((ur->psr&PSRPSUPER) == 0) | |
| 1991/1113 | *(ulong*)(USTKTOP-BY2WD) += TK2MS(1); | |
| 1990/1223 | } } | |