huw@xstuart.siesoft.co.uk (Huw Roberts) (02/09/90)
I remember there was a discussion a little while ago on coroutines/ lightweight processes and portable ways of implementing them in C. I think the original subject was "Jumping then jumping back again". I wonder if someone would be good enough to send me a summary of the conclusions of the mail thread since I do not believe we have any way of getting access to an archive of the discussion (we are not on Internet and have no access to ftp or niftp). My interest stems from the fact that I have implemented a "portable" way of handling multiple lightweight processes in C. The code works unchanged on MS/DOS, BSD4.2 and SYS5. If anyone is interested, mail me and I will send the source. Apologies if I am covering old ground/reopening old wounds here. Huw. ------------------------------------------------------------------------------- Name Huw Roberts Siemens Plc., System Development Group, Mail. huw@siesoft.co.uk Woodley House, 65-73, Crockhamwell Road, Tel. +44 734 443068 Woodley, Reading, Fax. +44 734 698874 Berkshire, RG5 3JP England. -------------------------------------------------------------------------------
bvs@light.uucp (Bakul Shah) (02/10/90)
In article <1797@neon.siesoft.co.uk> huw@xstuart.siesoft.co.uk (Huw Roberts) writes: >I remember there was a discussion a little while ago on coroutines/ >lightweight processes and portable ways of implementing them in C. >I think the original subject was "Jumping then jumping back again". >I wonder if someone would be good enough to send me a summary of the >conclusions of the mail thread since I do not believe we have any way >of getting access to an archive of the discussion (we are not on >Internet and have no access to ftp or niftp). There were many such threads.... Here is one point of view based on implementing coroutines on two very different architectures. To implement coroutines what is needed is an ability to save and restore a coroutine's context (which consists of, usually, all of the registers minus the temps that get destroyed across a call). On many machines, but not all, this is effectively what the setjmp/logjmp routines do so on these machines you can implement coroutines entirely in C. On machines with setjmp/longjmp that are smarter and/or more picky you will need some assembly glue. Then there are machines with two stacks (register stack & memory stack) which add their own complication. Also note that N coroutines will *need* N stacks but C does not need more than one (assuming a new frame is not malloced on every call). A C machine with only one stack (and no way to switch it) can be strictly standard conforming and yet won't allow you any coroutines (you can emulate them but that is different). I think if you *want* portable coroutines in C, you have to add some standard extension to it. Something like old_stack = stack_switch(new_stack) will do. The point is, in order to manage processor registers properly the coroutine context switcher and the compiler have to collaborate. Also, the extended language would have to guarantee sane behavior when stacks are switched. -- Bakul Shah ..!{ames,sun,ucbvax,uunet}!amdcad!light!bvs
woody@rpp386.cactus.org (Woodrow Baker) (02/11/90)
In article <1797@neon.siesoft.co.uk>, huw@xstuart.siesoft.co.uk (Huw Roberts) writes: > I remember there was a discussion a little while ago on coroutines/ > lightweight processes and portable ways of implementing them in C. > > My interest stems from the fact that I have implemented a "portable" > way of handling multiple lightweight processes in C. The code works > unchanged on MS/DOS, BSD4.2 and SYS5. If anyone is interested, mail > me and I will send the source. I for one, would love to have a copy. Perhaps you could email me one, or better yet, post it to comp.sources. (actualy I'll do that, if you send it to me...) Cheers Woody.
peter@ficc.uu.net (Peter da Silva) (02/15/90)
In article <1797@neon.siesoft.co.uk>, huw@xstuart.siesoft.co.uk (Huw Roberts)
asks for a summary of the LWP discussion...
I tried to send mail but 'xstuart' is refusing to accept mail for some reason.
Anyway, if you can come up with an address that will work I'l endeavour to
send you the stuff I have saved on this subject. I'd also be interested in
your LWP code. I collect the stuff...
--
_--_|\ Peter da Silva. +1 713 274 5180. <peter@ficc.uu.net>.
/ \
\_.--._/ Xenix Support -- it's not just a job, it's an adventure!
v "Have you hugged your wolf today?" `-_-'