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

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: {
1.1.1.2 ! root       16:        struct  sentry  *sptr;
        !            17:        struct  pentry  *pptr;
1.1       root       18: 
1.1.1.2 ! root       19:        disable();
1.1       root       20:        if (isbadsem(sem) || (sptr= &semaph[sem])->sstate==SFREE) {
1.1.1.2 ! root       21:                restore();
1.1       root       22:                return(SYSERR);
                     23:        }
                     24:        if (--(sptr->semcnt) < 0) {
                     25:                (pptr = &proctab[currpid])->pstate = PRWAIT;
                     26:                pptr->psem = sem;
                     27:                enqueue(currpid,sptr->sqtail);
                     28:                resched();
                     29:        }
1.1.1.2 ! root       30:        restore();
1.1       root       31:        return(OK);
                     32: }

unix.superglobalmegacorp.com

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