Memory not freed?
Jerry Feldman
gaf at blu.org
Sun Nov 26 08:33:18 EST 2000
I was generalizing, and yes I am sure. They use the page tables and mark
them as copy-on-write, so that when they get modified, the appropriate copy
is made. That makes the fork operation very fast, and there is very little
penalty paid by fork()/exec(). So:
pid = fork();
if (pid == 0) { /* child */
exec(.....);
}
In the above case, assuming pid can be held in a register, there is no
modification of the data segment, so none of the data segment pages need to
be copied. Once the child tries to write to a variable in the data
segment, then the page which holds that variable is duplicated.
"Derek D. Martin" wrote:
> You sure about that? It seems to me that sharing the text page makes
> perfect sense, but how would two different instances of the same
> program share the same data segments? That seems counter-intuitive,
> in that the data from each instance would almost certainly be different.
--
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix user group
http://www.blu.org
-
Subcription/unsubscription/info requests: send e-mail with
"subscribe", "unsubscribe", or "info" on the first line of the
message body to discuss-request at blu.org (Subject line is ignored).
More information about the Discuss
mailing list