Annotation of xinu/sys/recvtim.c, revision 1.1

1.1     ! root        1: /* recvtim.c - recvtim */
        !             2: 
        !             3: #include <conf.h>
        !             4: #include <kernel.h>
        !             5: #include <proc.h>
        !             6: #include <q.h>
        !             7: #include <sleep.h>
        !             8: 
        !             9: /*------------------------------------------------------------------------
        !            10:  *  recvtim  -  wait to receive a message or timeout and return result
        !            11:  *------------------------------------------------------------------------
        !            12:  */
        !            13: SYSCALL        recvtim(maxwait)
        !            14:        int     maxwait;
        !            15: {
        !            16:        struct  pentry  *pptr;
        !            17:        int     msg;
        !            18:        PStype  ps;
        !            19: 
        !            20:        if (maxwait<0 || clkruns == 0)
        !            21:                return(SYSERR);
        !            22:        disable(ps);
        !            23:        pptr = &proctab[currpid];
        !            24:        if ( !pptr->phasmsg ) {         /* if no message, wait          */
        !            25:                insertd(currpid, clockq, maxwait);
        !            26:                slnempty = TRUE;
        !            27:                sltop = (short *)&q[q[clockq].qnext].qkey;
        !            28:                pptr->pstate = PRTRECV;
        !            29:                resched();
        !            30:        }
        !            31:        if ( pptr->phasmsg ) {
        !            32:                msg = pptr->pmsg;       /* msg. arrived => retrieve it  */
        !            33:                pptr->phasmsg = FALSE;
        !            34:        } else {                        /* still no message => TIMEOUT  */
        !            35:                msg = TIMEOUT;
        !            36:        }
        !            37:        restore(ps);
        !            38:        return(msg);
        !            39: }

unix.superglobalmegacorp.com

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