Article View: comp.os.msdos.programmer
Article #2138TC++ coroutines with setjmp/longjmp.
From: Charles Noren
Date: Mon, 10 Sep 1990 16:23
Date: Mon, 10 Sep 1990 16:23
39 lines
2322 bytes
2322 bytes
Last night at home, reading my TC++ manuals, I came across the good old
setjmp/longjmp library calls. I've never used them before because of
the inherently non-portable and non-structured nature of the calls.
However, now I am curious about the feasibility of faking a primitive
"multi-tasking" application in TC++ with setjmp/longjmp. I know that
these functions can be used in setting up coroutines, and the manual
mentions the possibility of several stacks (with appropriate caveats of
not to use the overlay system).
What I would like to do (on my humble 8088 system with only 640K -- I
remember the days when I had an 8080 with 48K and felt like a king, but
I digress) is setup a 4 "process" (maybe more, maybe less) system, where
each "process" follows the discipline of voluntarily calling a function
that would save the context (via setjmp) and then executes a scheduler
which would choose (arbitrary choice, does not matter how for this
discussion) one of four setjmp contexts in which to perform a longjmp
to. Has anyone tried this sort of thing and have any pointers to share?
I was thinking for having each "process" have its own stack. I haven't
RFTM enough to find out how to do this in TC++ (prefer to stay in C/C++,
but will do some TASM if necessary) or what the dangers are. I would
like to implement this in different memory models and would like some
words of wisdom on what I need to do and look out for.
This is merely a recreational home exercise, no urgency, and if there
are no replies I will hack (kids and wife permitting) until I find out
something. I also want to stick with MS-DOS (3.X -- 3.1 is what I have)
even though there are some very fine DOS alternatives that will do what
I want.
Thanks,
--
Chuck Noren
NET: dinl!noren@ncar.ucar.edu
US-MAIL: Martin Marietta I&CS, MS XL8058, P.O. Box 1260,
Denver, CO 80201-1260
Phone: (303) 971-7930
Technical Details
Message-ID:
<1727@dinl.mmc.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!noao!ncar!dinl!norenShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!noao!ncar!dinl!noren From: noren@dinl.uucp (Charles Noren) Newsgroups: comp.os.msdos.programmer Subject: TC++ coroutines with setjmp/longjmp. Message-ID: <1727@dinl.mmc.UUCP> Date: 10 Sep 90 16:23:15 GMT Reply-To: noren@dinl.UUCP (Charles Noren) Organization: Martin Marietta I&CS, Denver CO. Lines: 39