Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Jan 1997 08:26:28 -0500 (EST)
From:      "Ron G. Minnich" <rminnich@Sarnoff.COM>
To:        A JOSEPH KOSHY <koshy@india.hp.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Using rfork() / threads
Message-ID:  <Pine.SUN.3.91.970130081328.9307F-100000@terra>
In-Reply-To: <199701301149.AA268284982@fakir.india.hp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SUN.3.91.970130081328.9307F-100000>