BSD daemon

NetBSD Documentation:

Why implement traditional vfork()

vfork() is designed to be used in the specific case where the child will exec() another program, and the parent can block until this happens. A traditional fork() required duplicating all the pages of the parent process in the child - a significant overhead.

The Mach VM system added COW (Copy On Write), which made fork() much cheaper, and in BSD 4.4, vfork() was made synonymous to fork(). After NetBSD 1.3 a traditional vfork() was reimplemented.

A good amount of effort was directed at making COW better in UVM, but an address space-sharing vfork() still turns out to be a win. It shaves several seconds off a build of libc on a 200MHz PPro.

vfork()/exec() using the 4.4BSD vfork() and COW:

The 3.0BSD/NetBSD vfork(), using address space sharing: So, in the case where you're going to fork and then exec, the latter case is clearly faster. Even if your COW algorithms are good, you still have to do a lot more work compared to the vmspace-sharing case!


Up to NetBSD Documentation: Kernel
NetBSD Home Page
NetBSD Documentation top level

(Contact us) $NetBSD: vfork.html,v 1.18 2004/10/30 22:33:26 jschauma Exp $
Copyright © 1994-2003 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.