| plan 9 kernel history: overview | file list | diff list |
1991/1113/ss/clock.c (diff list | history)
| ss/clock.c on 1990/1223 | ||
| 1990/1223 | #include "u.h" #include "lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" #include "ureg.h" void delay(int ms) { ulong t, *p; int i; | |
| 1990/1226 | ms *= 2000; /* 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/1113 | ulong i, ss, nrun = 0; Segment *s; | |
| 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); | |
| 1990/1227 | if((ur->psr&SPL(0xF))==0 && p && p->state==Running){ | |
| 1991/0821 | if(anyready()){ if(p->hasspin) p->hasspin = 0; else sched(); } | |
| 1991/0711 | if((ur->psr&PSRPSUPER) == 0){ | |
| 1991/1113 | ss = spllo(); /* Low because we may fault */ *(ulong*)(USTKTOP-BY2WD) += TK2MS(1); | |
| 1991/1111 | notify(ur); | |
| 1991/1113 | splx(ss); /* return hi for restore */ | |
| 1991/0711 | } | |
| 1990/1223 | } } | |