raph@tigger.planet.bt.co.uk (Raphael Mankin) (09/12/89)
peter@ficc.uu.net (Peter da Silva) writes: >In article <10861@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn) writes: >> In article <5899@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes: >> >If [simple setjmp] is used, it should be possible to create >> >a fake stack frame and register set in a jmp_buf and tranfer control to it >> >using longjmp. >> You need separate (non-overlapping) stacks, not just a stack frame. >> Otherwise the coroutines will step on each other's <DELETED>. Provided you setjmp/longjmp saves tnd restores he full stack pointer (MSDOS users beware here) it is quite possible to write coroutines in C. I have in fact written a full multi-tasking supervisor (coroutines with frills) entirely in C. This runs under MSC and the only kludge is two lines of assembly code to do the initial stack-frame setup for new tasks. -- Raphael Mankin raph@planet.bt.co.uk