Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!spool.mu.edu!uwm.edu!csd4.csd.uwm.edu!markh From: markh@csd4.csd.uwm.edu (Mark William Hopkins) Newsgroups: comp.os.msdos.programmer Subject: Re: Multi-thread on Ms-dos Message-ID: <10592@uwm.edu> Date: 29 Mar 91 01:48:41 GMT References: <104499@unix.cis.pitt.edu> <1991Mar22.155529.22@cpqhou.uucp> Sender: news@uwm.edu Distribution: comp.sys.ibm.pc.programmer,comp.sys.ibm.pc.misc Organization: University of Wisconsin - Milwaukee Lines: 27 In article <104499@unix.cis.pitt.edu> bill@hpb.cis.pitt.edu (Bill Broadly) writes: > I need a small C program that allows running more that >one thread, using setjmp, and longjmp, on a ms-dos machine. Nothing >pre-emptive needed. In article <1991Mar22.155529.22@cpqhou.uucp> pipkinsj@cpqhou.UUCP (Jeff Pipkins @Adv Dev@SE hou ) writes: >This is a nice thought, but it doesn't work. I actually tried this scenario, >but the problem is that all threads have the same stack. As soon as any >one of them do a longjmp(), it throws away a piece of the stack. You'll have to elaborate on this one. The longjmp() routine saves the current stack pointer, and whether a part of the stack is thrown away or not, when you start up the next thread with another longjmp() the stack pointer is switched there over to another completely different part of the stack segment before the previous part of the stack segment has had a chance to get corrupted. >There are certain very simple situations in which it seems to work, usually >in a program called test.c :) I actually got test.c to switch data segments under certain cases too thus allowing rudimentary swapping. :) >There is a way to do something similar to coroutines with setjmp/longjmp, >but it is rather delicate and unelegant. In the Empire Strikes Back, to Obi-Wan's lament "That boy is our last hope", Yoda said "No, there is another...". Don't leave us waiting 3 years. :)