Annotation of xinu/sys/resched.c, revision 1.1.1.2

1.1       root        1: /* resched.c  -  resched */
                      2: 
                      3: #include <conf.h>
                      4: #include <kernel.h>
                      5: #include <proc.h>
                      6: #include <q.h>
                      7: 
                      8: /*------------------------------------------------------------------------
                      9:  * resched  --  reschedule processor to highest priority ready process
                     10:  *
                     11:  * Notes:      Upon entry, currpid gives current process id.
                     12:  *             Proctab[currpid].pstate gives correct NEXT state for
1.1.1.2 ! root       13:  *                     current process if other than PRREADY.
1.1       root       14:  *------------------------------------------------------------------------
                     15:  */
                     16: int    resched()
                     17: {
                     18:        register struct pentry  *optr;  /* pointer to old process entry */
                     19:        register struct pentry  *nptr;  /* pointer to new process entry */
                     20: 
                     21:        /* no switch needed if current process priority higher than next*/
                     22: 
                     23:        if ( ( (optr= &proctab[currpid])->pstate == PRCURR) &&
1.1.1.2 ! root       24:           (lastkey(rdytail)<optr->pprio)) {
1.1       root       25:                return(OK);
1.1.1.2 ! root       26:        }
1.1       root       27: 
                     28:        /* force context switch */
                     29: 
                     30:        if (optr->pstate == PRCURR) {
                     31:                optr->pstate = PRREADY;
                     32:                insert(currpid,rdyhead,optr->pprio);
                     33:        }
                     34: 
                     35:        /* remove highest priority process at end of ready list */
                     36: 
                     37:        nptr = &proctab[ (currpid = getlast(rdytail)) ];
                     38:        nptr->pstate = PRCURR;          /* mark it currently running    */
                     39: #ifdef RTCLOCK
                     40:        preempt = QUANTUM;              /* reset preemption counter     */
                     41: #endif
1.1.1.2 ! root       42:        ctxsw(optr->pregs,nptr->pregs);
        !            43: 
        !            44:        /* The OLD process returns here when resumed. */
        !            45: 
1.1       root       46:        return(OK);
                     47: }

unix.superglobalmegacorp.com

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