Re: Multiple instances of program sharing same text segment ?

From: Jeffrey Hundstad
Date: Tue Mar 20 2007 - 15:42:01 EST


Keep in mind that while the text of the program IS SHARED any configuration file that is then loaded into ram after the execution IS NOT SHARED.

BTW you can find out what is shared and not by taking a look at the proc files:

# ps auxwww | grep emacs | grep -v grep # -- find the pids
user 21529 0.2 0.3 16784 7560 pts/11 S+ 14:27 0:00 xemacs -nw
user 21549 0.2 0.3 16784 7548 pts/12 S+ 14:27 0:00 xemacs -nw

# cat /proc/21529/maps |grep xemacs | grep "r-xp" # -- find the mapped text executable
08048000-081f5000 r-xp 00000000 08:02 201672393 /usr/bin/xemacs-21.4.19-nomule

# cat /proc/21549/maps |grep xemacs | grep "r-xp" # -- find the mapped text executable
08048000-081f5000 r-xp 00000000 08:02 201672393 /usr/bin/xemacs-21.4.19-nomule

#ls -li /usr/bin/xemacs-21.4.19-nomule # -- confirm that 201672393 is the inode we're looking at.
201672393 -rwxr-xr-x 1 root root 1800764 2006-11-03 11:11 /usr/bin/xemacs-21.4.19-nomule


Jeremy Fitzhardinge wrote:
Ravinandan Arakali (rarakali) wrote:
I note that do_exec calls do_mmap to map the executable file to memory.
But not sure what happens(w.r.t text sharing) when another instance of the program is invoked. BTW, this is 2.6.10.

Yes, they will be shared. As far as the rest of the kernel is
concerned, an mmap is an mmap is an mmap, and the pages will be shared.

J
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/