Path: utzoo!attcan!uunet!mcvax!ukc!edcastle!lfcs!sam From: sam@lfcs.ed.ac.uk (S. Manoharan) Newsgroups: comp.lang.c Subject: Re: Coroutines in C Message-ID: <214@castle.ed.ac.uk> Date: 22 Aug 89 21:40:20 GMT Sender: root@castle.ed.ac.uk Reply-To: sam@lfcs.ed.ac.uk (S. Manoharan) Lines: 33 In article <5773@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes: > > In many C compilers I wouldn't even need >to write any assembly code, since setjmp/longjmp can be used to implement >the context switch. I have a question. Consider these functions: event1() event2() { { . . . . . . get_resourceX(); . . . /*resume:*/ . . . . . . } } event1() requsts for resourceX. If resourceX is not available then I want event1() to suspend, and some other event, say event2() to start. Perhaps, event2() could make the resourceX available. Once the resourceX is available, I want the function event1() to start from the /*resume:*/ point. (The code upto the /*resume:*/ point in event1() should not be re-executed) Intutively, it appears the co-routines could be applied in this context. Am I correct? And then, is there an easy way to tackle this problem? Since there could be a number of event?()s, I think setjmp() and longjmp() would be of no help. Janet: sam@uk.ac.ed.lfcs S. Manoharan Uucp : ..!mcvax!ukc!lfcs!sam Dept of Computer Science Arpa : sam%lfcs.ed.ac.uk@nsfnet-relay.ac.uk University of Edinburgh Voice: 031-667 5076 (home) Edinburgh EH9 3JZ UK.