Re: copy-on-write overhead

2010-01-11 Thread Manish Katiyar
that can be avoided, that does not happen because it >> >> would've already been copied before exec() in the child gets a chance >> >> to execute.. the fork system call calls do_fork somewhere which calls >> >> copy_process which does this copying so it ca

Re: copy-on-write overhead

2010-01-11 Thread askb
On Mon, 2010-01-11 at 15:01 +0530, Pete wrote: > After going through this thread, I just tried out the following simple > code: > > int main (void) { > > int pid; > > int *testVar = (int *) malloc (sizeof (int)); > > *testVar = 10; > > printf ("%d [%d] Main \n", *testVar, testVar); > > pid=

Re: copy-on-write overhead

2010-01-11 Thread Pete
ould've already been copied before exec() in the child gets a chance > >> to execute.. the fork system call calls do_fork somewhere which calls > >> copy_process which does this copying so it can't be avoided in any > >> case. The book says copy-on-write itself h

Re: copy-on-write overhead

2010-01-10 Thread Joel Fernandes
that does not happen because it >> would've already been copied before exec() in the child gets a chance >> to execute.. the fork system call calls do_fork somewhere which calls >> copy_process which does this copying so it can't be avoided in any >> case. The bo

Re: copy-on-write overhead

2010-01-10 Thread Nagaprabhanjan Bellari
> > Hi Joel... > > Manish is right. Please notice that he talked about "why do we do copy > on write (COW) if soon after child is forked, it quickly does exec()". > So yes, COW has overhead, but imagine if parent ran first. COW will be > triggered for parent address

Re: copy-on-write overhead

2010-01-10 Thread Mulyadi Santosa
tem call calls do_fork somewhere which calls > copy_process which does this copying so it can't be avoided in any > case. The book says copy-on-write itself has more overhead that is > avoided with exec() in the child, but I'm trying to figure how. > > -Joel Hi Joel... Mani

Re: copy-on-write overhead

2010-01-10 Thread Joel Fernandes
which does this copying so it can't be avoided in any case. The book says copy-on-write itself has more overhead that is avoided with exec() in the child, but I'm trying to figure how. -Joel On Mon, Jan 11, 2010 at 12:18 AM, Manish Katiyar wrote: > On Mon, Jan 11, 2010 at 12:02 AM

Re: copy-on-write overhead

2010-01-10 Thread Joel Fernandes
>> How does running exec() in child more efficient than having >> copy-on-write trigger in the parent? > > In order to create a new process (fork), you will copy the whole of > relevant info of address space from the parent. Now if the address > space is shared and parent r

Re: copy-on-write overhead

2010-01-10 Thread Manish Katiyar
gt; system call. > > Quoting Pg 32 (2nd edition): > "In do_fork() the child is woken up and run. Deliberately the kernel > runs the child process first. In the common case of the child simply > calling exec() immediately, this eliminates any copy-on-write overhead > that would occur if

copy-on-write overhead

2010-01-10 Thread Joel Fernandes
d run. Deliberately the kernel runs the child process first. In the common case of the child simply calling exec() immediately, this eliminates any copy-on-write overhead that would occur if the parent ran first and began writing to the address space" How does running exec() in child more effi

Re: Copy-on-Write

2008-02-07 Thread Brandon Philips
On 22:30 Thu 07 Feb 2008, Mulyadi Santosa wrote: > On Feb 6, 2008 12:49 PM, Rick Brown <[EMAIL PROTECTED]> wrote: > > So in linux, is a child run first or the parent? Can we rely on this > > information? > > Hm, this might be the answer: > http://lxr.linux.no/linux/kernel/sched.c#L1663 > > it say

Re: Copy-on-Write

2008-02-07 Thread Mulyadi Santosa
Hi On Feb 6, 2008 12:49 PM, Rick Brown <[EMAIL PROTECTED]> wrote: > So in linux, is a child run first or the parent? Can we rely on this > information? Hm, this might be the answer: http://lxr.linux.no/linux/kernel/sched.c#L1663 it says: unsigned int __read_mostly sysctl_sched_child_runs_fir

Copy-on-Write

2008-02-06 Thread Rick Brown
Hi, I had read that the operating systems that use copy-on-write mechanism for fork(), it is better if they deliberately allow the CHILD to run first. This would be better because in 99% of the cases child will call exec() and the new address space will be allocated. Instead if the parent is

RE: Copy-on-Write

2008-02-06 Thread Rajat Jain
Hi, >> >> I had read that the operating systems that use copy-on-write >> mechanism for fork(), it is better if they deliberately allow the >> CHILD to run first. >> >> This would be better because in 99% of the cases child will call >> exec() a

Re: Copy-on-Write

2008-02-06 Thread Manish Katiyar
On Feb 6, 2008 6:03 PM, Rajat Jain <[EMAIL PROTECTED]> wrote: > > Hi, > > >> > >> I had read that the operating systems that use copy-on-write > >> mechanism for fork(), it is better if they deliberately allow the > >> CHILD to run first. > &g

Re: Copy-on-Write

2008-02-06 Thread Manish Katiyar
On Feb 6, 2008 11:19 AM, Rick Brown <[EMAIL PROTECTED]> wrote: > Hi, > > I had read that the operating systems that use copy-on-write mechanism > for fork(), it is better if they deliberately allow the CHILD to run > first. > > This would be better because in 99% o