Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!lll-winken!sun-barr!ccut!titcca!cc.titech.ac.jp!necom830!mohta From: mohta@necom830.cc.titech.ac.jp (Masataka Ohta) Newsgroups: comp.arch Subject: Re: fork() vs vfork() and COW Message-ID: <5829@titcce.cc.titech.ac.jp> Date: 11 Jul 90 03:14:02 GMT References: <1122@sirius.ucs.adelaide.edu.au> <3830012@hpcupt1.HP.COM> <58053@bbn.BBN.COM> <476@exodus.Eng.Sun.COM> Sender: news@cc.titech.ac.jp Organization: Tokyo Institute of Technology Lines: 36 In article <476@exodus.Eng.Sun.COM> david@eng.sun.com (Big Ed's Gas Farm) writes: >I timed a simple test program on a Sun 4/60 running SunOS 4.1 (has COW): >fork() seems to take twice as long as vfork() for a small process. But, you should have measured fork() time of a large process. >#include >#include ! !#define SIZE (100*1024*1024) !char mem[SIZE]; > >main(argc) > int argc; >{ > int i, pid; > > signal(SIGCHLD, SIG_IGN); ! ! for(i=0;i > for (i = 0; i < 10000; i++) { > pid = argc > 1 ? vfork() : fork(); > if (pid == 0) ! _exit(0); ! else ! wait(0); /* unless you want to spwan 10000 processes ! at the same time */ > } >} Masataka Ohta