From owner-freebsd-hackers Thu Jan 30 05:29:33 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id FAA10636 for hackers-outgoing; Thu, 30 Jan 1997 05:29:33 -0800 (PST) Received: from terra.Sarnoff.COM (terra.sarnoff.com [130.33.11.203]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id FAA10630 for ; Thu, 30 Jan 1997 05:29:31 -0800 (PST) Received: (from rminnich@localhost) by terra.Sarnoff.COM (8.6.12/8.6.12) id IAA09489; Thu, 30 Jan 1997 08:26:28 -0500 Date: Thu, 30 Jan 1997 08:26:28 -0500 (EST) From: "Ron G. Minnich" X-Sender: rminnich@terra To: A JOSEPH KOSHY cc: freebsd-hackers@freebsd.org Subject: Re: Using rfork() / threads In-Reply-To: <199701301149.AA268284982@fakir.india.hp.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk On Thu, 30 Jan 1997, A JOSEPH KOSHY wrote: > I'm looking at porting a linux program that uses `clone()' and was > considering the BSD `rfork()' as an equivalent. My questions are: > Do we have an equivalent for Linux `sched_yield()'? well, i wrote one a few years back for freebsd but it never got put in. It's a trivial call. They used to look like this (Wally Kimura, then of IBM, was the originator of this as far as I know) yield() { runrun++; } Looking at my current kernel source it seems you need to: yield() { want_resched++; } Corrections appreciated. > How light weight is the process created by `rfork()' (assuming > that we share everything possible to be shared)? Not light at all. It shares things with the other process, but it is a full process in its own right. You really ought to check out the latest context switch times for freebsd before assuming that is bad. As Rob Pike once said, and I quote semi-accurately, threads are needed for systems that have poor context switch performance. Translation: that doesn't mean they're needed. If you request file descriptor sharing, then the fd tables are shared between processes: if one opens a file, the other will see it. VM space handling is a little different. If you request VM space sharing, you don't exactly get Vm address space sharing: what you get is instead shared data areas where in normal fork they are copied. More details on request. The effect is what you want, though: shared data areas. > I'm not really looking at a complete emulation of `clone()'; just enough > to get equivalent functionality. Going by my reading of my linux kernel source, rfork gives more than enough. ron