Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Memory not freed?



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).




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org