From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f678f,2aedba6752dd2388 X-Google-Attributes: gidf678f,public X-Google-ArrivalTime: 1993-10-14 10:16:46 PST Newsgroups: comp.unix.osf.misc Path: gmd.de!xlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!uunet!tarpit!gator!aaahq05!sparc32!swh From: swh@aaahq05.aaa.com (Steven Wayne Hudson) Subject: Re: Threads better than forks? Message-ID: Sender: news@aaahq05.aaa.com (USENET Administrator) Nntp-Posting-Host: sparc32 Reply-To: swh@aaahq05.aaa.com Organization: American Automibile Association - National Headquarters References: Date: Thu, 14 Oct 1993 15:22:40 GMT In article 93Oct11183950@hpltp.hpl.hp.com, thuan@hpltp.hpl.hp.com (Thuan Q. Pham) writes: > In article mauney@adm.csc.ncsu.edu (Jon Mauney) writes: > > > a) Fork is usually a fairly heavyweight operation. Creating a thread > > should be fairly fast > > Yes, forking a process is much more expensive than spawning thread because > of the overhead. To create a process, the system must set up the address > space and other system resources (memory pages, file descriptors, etc. etc..) > > In a multithreaded process (Mach calls it "task"), threads within the same > process share all of the process's resources, so creating a thread is a > cheap operation: setting up the thread running context (program counter, > registers set, etc...). It inherits the rest from the parent process. > And since threads share the process's resources, communication between them > can be done very naturally and efficiently with shared memory. > O.K. So how do you create a thread? Also, what is the functional (NOT operational) difference between a thread and fork? --- Steve Hudson /// swh@aaahq05.aaa.com (0 0) -----------------------------ooO-(_)-Ooo---------------------------------