home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / s / s001 / 1.ddi / TS / SRC / CREQ.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-08-22  |  1.2 KB  |  38 lines

  1.                 /******************************************
  2.            *            CREQ.C             *
  3.                * Copyright TimeSlice, Inc. 1985, 86, 87. *
  4.                ******************************************/
  5.  
  6. #include <ts.h>
  7.  
  8. /**********
  9. * CREQ( CN , MODE )
  10. * This function waits until the proper flag CN->wf or CN->rf is NULL and then
  11. * sets it to curproc
  12. **********/
  13. void creq( cn , mode )
  14. CHAN *cn ;
  15. int  mode ;
  16. {
  17.   int cpuflags ;
  18.   PROCESS **ppp, *pp;
  19.  
  20.   cpuflags = cli() ;                /* hold interrupts */
  21.   ppp = (mode == 'w') ? &cn->wf : &cn->rf;    /* point to rf or wf to test */
  22.   if( !*ppp )                    /* channel not requested yet*/
  23.     *ppp = curproc;                /* request it for curproc*/
  24.   if( *ppp == curproc )                /* requested by self */
  25.     goto CREQEND;
  26.   curproc->status |= CHANWAIT;            /* channel held by someone else*/
  27.   pp = *ppp;                    /* pp <-- holding process */
  28.   while( pp->chnxt )                /* find end of process waiting list */
  29.     pp = pp->chnxt;
  30.   pp->chnxt = curproc;                /* append curproc to end of list*/
  31.   guc();                    /* wait tobe awakened*/
  32. CREQEND:
  33.   curproc->chlev++;                /* update channel request level*/
  34.   putf( cpuflags ) ;                /* restore interrupt state */
  35. }
  36.  
  37.  
  38.