home *** CD-ROM | disk | FTP | other *** search
- /* This source file is part of the LynxLib miscellaneous library by
- Robert Fischer, and is Copyright 1990 by Robert Fischer. It costs no
- money, and you may not make money off of it, but you may redistribute
- it. It comes with ABSOLUTELY NO WARRANTY. See the file LYNXLIB.DOC
- for more details.
- To contact the author:
- Robert Fischer \\80 Killdeer Rd \\Hamden, CT 06517 USA
- (203) 288-9599 fischer-robert@cs.yale.edu */
-
- /* Coroutine C code */
- #include "co.h"
-
- BOOLEAN init_co(f, arg, stacksize, p)
- /* Returns FALSE on error */
- func *f; /* Cofunction to init */
- LONG arg; /* Argument to that function */
- long stacksize; /* Size of stack to make */
- pcb *p; /* Process stack ID to put stack in */
- {
- /* Init the process' stack */
- if ((p->stack_base = lmalloc(stacksize)) == NULL) return FALSE;
- p->stack = p->stack_base + stacksize;
-
- /* Init the process */
- init_co_s(f, arg, p);
- }
- /* -------------------------------------------------------- */
- kill_co(p) /* This kills a coroutine by freeing its stack */
- pcb *p;
- {
- free(p->stack_base);
- }
- /* -------------------------------------------------------- */
-