in reply to Creating Child without overhead of Parent

Pretty much all modern OSes provide for very light weight forking, using Copy On Write as Broquaint mentions. What this means is that sections of the memory of the child process are references to the memory of the parent process, up until the point where either process writes to a particular memory section, at which point it is copied and the child process proceeds to have its memory references to that section refer to the copy. If this were not the case, then the fork/exec paradigm would be woefully expensive. As it stands, doing a fork/exec does not chew up any real overhead because the child process starts, and then is immediately wiped by the exec. I think that this is a reason for operating systems to favor giving the child process priority to run, since if it is going to exec some other program, this lets it get it off quickly, before the parent process can write to any memory, thus forcing the child to have a copy of it made.
  • Comment on Re: Creating Child without overhead of Parent