home *** CD-ROM | disk | FTP | other *** search
- /******************************************
- * ENDSELF.C *
- * Copyright TimeSlice, Inc. 1985, 86, 87. *
- ******************************************/
-
-
- #include <ts.h>
-
-
- /**********
- * ENDSELF()
- * Called either voluntarily or automatically when a process returns.
- * It removes the curproc from the process list.
- **********/
- void endself() {
- PROCESS *p;
- CRCLASS *crcptr;
-
- for( crcptr = crit_tab ; crcptr < crit_stop ; crcptr++ )
- if( crcptr->crcur == curproc ) {
- crcptr->crlev = 1;
- critend( crcptr - crit_tab );
- }
- curproc->crlev = 0;
- critstart( DOS_CRCLASS );
- if( curproc->nxt == curproc ) /*if last process...*/
- exitmp(0); /*...terminate application*/
- ssleep();
- for( p = curproc ; p->nxt != curproc ; p = p->nxt ); /*find predecesor*/
- p->nxt = curproc->nxt; /*take curproc out of process list*/
- _ts_free( curproc->name ); /*free its process structure & stack*/
- critend( DOS_CRCLASS );
- curproc = (PROCESS *)(((char*)curproc)+8); /*move freed curproc beyond...*/
- curproc->nxt = p->nxt; /*some bytes used by free,and set nxt*/
- _sslev = 1 ; /*make sure to wake up switcher*/
- swake();
- guc(); /*wait for death to do its part*/
- }
-
-
-