Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!samsung!usc!elroy.jpl.nasa.gov!ncar!zaphod.mps.ohio-state.edu!lavaca.uh.edu!menudo.uh.edu!nuchat!sugar!peter From: peter@sugar.hackercorp.com (Peter da Silva) Newsgroups: comp.sys.amiga.misc Subject: Re: Multitasking Definitions (Was: True Multitasking) Message-ID: <7707@sugar.hackercorp.com> Date: 4 Feb 91 23:41:21 GMT References: <7641@sugar.hackercorp.com> Organization: Sugar Land Unix -- Houston, TX Lines: 34 In article mwm@pa.dec.com (Mike (My Watch Has Windows) Meyer) writes: > In article <7641@sugar.hackercorp.com> peter@sugar.hackercorp.com (Peter da Silva) writes: > What state is this? A coroutine's state is just its stack, and that's saved > by the co-call. > Yes, there's very little state. But it's saved by the co-call, which > is part of your program. Not at all, it might be a system call. In fact, in some realtime execs it *is* a system call, the core of the scheduler, and LWPs are built on top of co-call. It gives you more control of the task in a hard real-time situation. > You deleted the comparison to LWPs, where the > state is saved by something outside of your program. And, again, LWPs are implemented in many ways. I've implemented LWPs on top of coroutines to get a multithreaded Forth system running under RSX-11 and CP/M-80. It ran fine on the 8080, though when Karl added a clock interrupt and made the threads run pre-emptively we had to put a semaphore around all the BDOS and BIOS calls. > Ok, so it depends on what you consider a "lot". As an exercise, > implementing co-routines isn't a lot of fuss. As part of another > project where it's a distraction from solving the problem, it can be. True, but that's got nothing to do with whether or not there's any magic difference between LWPs and coroutines. There isn't. LWPs inherently have little more state than coroutines. The only difference is the existence of a routine to handle the scheduling... instead of "co-call(routine)" it's "co_call(self->next)". -- Peter da Silva. `-_-' .