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

  1.                 /******************************************
  2.            *           ENDSELF.C             *
  3.                * Copyright TimeSlice, Inc. 1985, 86, 87. *
  4.                ******************************************/
  5.  
  6.  
  7. #include <ts.h>
  8.  
  9.  
  10. /**********
  11. * ENDSELF()
  12. * Called either voluntarily or automatically when a process returns.
  13. * It removes the curproc from the process list.
  14. **********/
  15. void endself() {
  16.   PROCESS *p;
  17.   CRCLASS *crcptr;
  18.  
  19.   for( crcptr = crit_tab ; crcptr < crit_stop ; crcptr++ )
  20.     if( crcptr->crcur == curproc ) {
  21.       crcptr->crlev = 1;
  22.       critend( crcptr - crit_tab );
  23.     }
  24.   curproc->crlev = 0;
  25.   critstart( DOS_CRCLASS );
  26.   if( curproc->nxt == curproc )        /*if last process...*/
  27.     exitmp(0);                /*...terminate application*/
  28.   ssleep();
  29.   for( p = curproc ; p->nxt != curproc ; p = p->nxt );    /*find predecesor*/
  30.   p->nxt = curproc->nxt;        /*take curproc out of process list*/
  31.   _ts_free( curproc->name );        /*free its process structure & stack*/
  32.   critend( DOS_CRCLASS );
  33.   curproc = (PROCESS *)(((char*)curproc)+8); /*move freed curproc beyond...*/
  34.   curproc->nxt = p->nxt;        /*some bytes used by free,and set nxt*/
  35.   _sslev = 1 ;                /*make sure to wake up switcher*/
  36.   swake();
  37.   guc();                /*wait for death to do its part*/
  38. }
  39.  
  40.  
  41.