Annotation of lucent/sys/src/9/gnot/clock.c, revision 1.1

1.1     ! root        1: #include       "u.h"
        !             2: #include       "../port/lib.h"
        !             3: #include       "mem.h"
        !             4: #include       "dat.h"
        !             5: #include       "fns.h"
        !             6: #include       "io.h"
        !             7: 
        !             8: #include       "ureg.h"
        !             9: 
        !            10: void
        !            11: delay(int ms)
        !            12: {
        !            13:        int i;
        !            14: 
        !            15:        ms *= 1000;     /* experimentally determined */
        !            16:        for(i=0; i<ms; i++)
        !            17:                ;
        !            18: }
        !            19: 
        !            20: void
        !            21: clock(Ureg *ur)
        !            22: {
        !            23:        Proc *p;
        !            24:        int user, nrun = 0;
        !            25: 
        !            26:        user = (ur->sr&SUPER) == 0;
        !            27:        if(user){
        !            28:                u->dbgreg = ur;
        !            29:                u->p->pc = ur->pc;
        !            30:        }
        !            31: 
        !            32:        SYNCREG[1] = 0x5F;      /* clear interrupt */
        !            33:        m->ticks++;
        !            34:        p = m->proc;
        !            35:        if(p){
        !            36:                nrun = 1;
        !            37:                p->pc = ur->pc;
        !            38:                if (p->state==Running)
        !            39:                        p->time[p->insyscall]++;
        !            40:        }
        !            41:        nrun = (nrdy+nrun)*1000;
        !            42:        MACHP(0)->load = (MACHP(0)->load*19+nrun)/20;
        !            43:        checkalarms();
        !            44:        kbdclock();
        !            45:        duartclock();
        !            46:        mouseclock();
        !            47:        dspclock();
        !            48:        kproftimer(ur->pc);
        !            49:        if((ur->sr&SPL(7)) == 0 && p && p->state==Running){
        !            50:                if(anyready()){
        !            51:                        if(p->hasspin)
        !            52:                                p->hasspin = 0;
        !            53:                        else
        !            54:                                sched();
        !            55:                }
        !            56:                if(user){
        !            57:                        (*(ulong*)(USTKTOP-BY2WD)) += TK2MS(1); /* profiling clock */
        !            58:                        notify(ur);
        !            59:                }
        !            60:        }
        !            61: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.