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

1.1     ! root        1: /* wait.c - wait */
        !             2: 
        !             3: #include <conf.h>
        !             4: #include <kernel.h>
        !             5: #include <proc.h>
        !             6: #include <q.h>
        !             7: #include <sem.h>
        !             8: 
        !             9: /*------------------------------------------------------------------------
        !            10:  * wait  --  make current process wait on a semaphore
        !            11:  *------------------------------------------------------------------------
        !            12:  */
        !            13: SYSCALL        wait(sem)
        !            14:        int     sem;
        !            15: {
        !            16:        PStype  ps;
        !            17:        register struct sentry  *sptr;
        !            18:        register struct pentry  *pptr;
        !            19: 
        !            20:        disable(ps);
        !            21:        if (isbadsem(sem) || (sptr= &semaph[sem])->sstate==SFREE) {
        !            22:                restore(ps);
        !            23:                return(SYSERR);
        !            24:        }
        !            25:        if (--(sptr->semcnt) < 0) {
        !            26:                (pptr = &proctab[currpid])->pstate = PRWAIT;
        !            27:                pptr->psem = sem;
        !            28:                enqueue(currpid,sptr->sqtail);
        !            29:                resched();
        !            30:        }
        !            31:        restore(ps);
        !            32:        return(OK);
        !            33: }

unix.superglobalmegacorp.com

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