Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!turnkey!orchard.la.locus.com!prodnet.la.locus.com!lccma.bos.locus.com!mjl From: mjl@lccma.bos.locus.com (Michael Leibensperger) Newsgroups: comp.os.mach Subject: Re: Threads, Definition of Summary: how threads differ from "shared memory processes" Keywords: thread, shared memory, page tables, process Message-ID: <21892@oolong.la.locus.com> Date: 11 Feb 91 17:58:01 GMT References: <4964@umbc3.UMBC.EDU> <1476@pdxgate.UUCP> Sender: news@locus.com Organization: Locus Computing Corporation --- Boston Office Lines: 31 Fcc: outbox In article <1476@pdxgate.UUCP> berggren@eecs.cs.pdx.edu (Eric Berggren) asks, how are lightweight process implementations different from regular processes using shared memory? As dmason@msg.uwaterloo.ca (Dave Mason) correctly points out, just what an LWP is depends on who you ask. The simple answer to "what is the difference between threads and regular procs using shared memory?" is that a thread or LWP shares *all* text and data except for the stack, while regular shared memory processes only share one or more named regions of memory. Moreover, LWPs share their memory *automatically* once the Nth (N>1) LWP is created, while shared memory procs must perform intricate rituals using shmat(), mmap(), or whatever before the named regions can be shared. Some thread/LWP implementations have no built in OS support and rely on runtime libraries to manage switching stack segments and register sets, essentially context switching the process's single thread among various activities. The advantages of having the OS know about threads (as in Mach) are: a) the OS can maintain a single set of page tables for all threads, reducing the context switch overhead when switching between two threads of the same task, and b) on an MP system the seperate threads can execute concurrently. I await my due share of fawning adoration.... ;-) mjl -- Michael J. Leibensperger "None are so deeply enslaved Locus Computing Corp./Boston as those who falsely believe 25 Burlington Mall Road they are free." Burlington MA 01803, (617)229-4980 x169 -- J. W. von Goethe