home *** CD-ROM | disk | FTP | other *** search
- /******************************************
- * CREQ.C *
- * Copyright TimeSlice, Inc. 1985, 86, 87. *
- ******************************************/
-
- #include <ts.h>
-
- /**********
- * CREQ( CN , MODE )
- * This function waits until the proper flag CN->wf or CN->rf is NULL and then
- * sets it to curproc
- **********/
- void creq( cn , mode )
- CHAN *cn ;
- int mode ;
- {
- int cpuflags ;
- PROCESS **ppp, *pp;
-
- cpuflags = cli() ; /* hold interrupts */
- ppp = (mode == 'w') ? &cn->wf : &cn->rf; /* point to rf or wf to test */
- if( !*ppp ) /* channel not requested yet*/
- *ppp = curproc; /* request it for curproc*/
- if( *ppp == curproc ) /* requested by self */
- goto CREQEND;
- curproc->status |= CHANWAIT; /* channel held by someone else*/
- pp = *ppp; /* pp <-- holding process */
- while( pp->chnxt ) /* find end of process waiting list */
- pp = pp->chnxt;
- pp->chnxt = curproc; /* append curproc to end of list*/
- guc(); /* wait tobe awakened*/
- CREQEND:
- curproc->chlev++; /* update channel request level*/
- putf( cpuflags ) ; /* restore interrupt state */
- }
-
-
-