Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!samsung!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!pa.dec.com!bacchus!mwm From: mwm@raven.relay.pa.dec.com (Mike (My Watch Has Windows) Meyer) Newsgroups: comp.sys.amiga.misc Subject: Multitasking Definitions (Was: True Multitasking) Message-ID: Date: 21 Jan 91 15:51:53 GMT References: <1991Jan18.055614.13889@zorch.SF-Bay.ORG> <42149@nigel.ee.udel.edu> <15750@sdcc6.ucsd.edu> Sender: news@pa.dec.com (News) Organization: Missionaria Phonibalonica Lines: 35 In-Reply-To: djohnson@beowulf.ucsd.edu's message of 19 Jan 91 01:47:13 GMT In article <15750@sdcc6.ucsd.edu> djohnson@beowulf.ucsd.edu (Darin Johnson) writes: In article <42149@nigel.ee.udel.edu> new@ee.udel.edu (Darren New) writes: >Please tell me the difference between coroutines and lightweight >processes. I always thought that lightweight processes were two >'tasks' (i.e., independant program counters) sharing the same address >space. Lightweight processes (LWP) and co-routines (CR) have much in common, and some people blur the definition. Usually however, LWP's have the ability to context switch anywhere, like any process. CR's need only change context at IO, semaphores, and other special calls. CR's are a language construct, whereas LWP's are an OS construct. CR's require much less OS and machine support, but require more compiler support (co-routines share the same stack, global vars, etc). That pretty much sums it up, but I'd have put it a different way (one which I think highlights the critical differences): LWPs are scheduled by an external entity as a set of independent threads of control; CRs are a single thread that is passed between the CRs, with each CR deciding when to pass it to another CR, and which one gets it, and taking responsibility for saving whatever state it needs to restart. Actually, to avoid confusion, compiler support is not needed. CR's can be done in assembler without much fuss - device drivers often do this (usually when LWP's are unavailable). Further, if you're willing to do the appropriate magic, you can get LWPs without OS support specifically for them; but it's a lot of fuss.