/proc/pid/maps


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers /proc/pid/maps
# 1  
Old 11-15-2011
/proc/pid/maps

I think the libc.so is shared between processes, because it is a shared library and OS is engaged for saving memory.
But, below, the maps of bash, shows r-xp and r--p rw-p attributes to libc.so which mean private memory space.
Can anybody explain this for me?
Code:
[alien@Fedora15~/Downloads]:)cat /proc/$$/maps
0014b000-00156000 r-xp 00000000 08:08 11720      /lib/libnss_files-2.13.90.so
00156000-00157000 r--p 0000a000 08:08 11720      /lib/libnss_files-2.13.90.so
00157000-00158000 rw-p 0000b000 08:08 11720      /lib/libnss_files-2.13.90.so
00d77000-00d78000 r-xp 00000000 00:00 0          [vdso]
08047000-0811b000 r-xp 00000000 08:08 59587      /bin/bash
0811b000-08120000 rw-p 000d4000 08:08 59587      /bin/bash
08120000-08125000 rw-p 00000000 00:00 0 
08598000-08765000 rw-p 00000000 00:00 0          [heap]
45d50000-45d6f000 r-xp 00000000 08:08 63638      /lib/ld-2.13.90.so
45d6f000-45d70000 r--p 0001f000 08:08 63638      /lib/ld-2.13.90.so
45d70000-45d71000 rw-p 00020000 08:08 63638      /lib/ld-2.13.90.so
45d77000-45eff000 r-xp 00000000 08:08 63639      /lib/libc-2.13.90.so
45eff000-45f01000 r--p 00188000 08:08 63639      /lib/libc-2.13.90.so
45f01000-45f02000 rw-p 0018a000 08:08 63639      /lib/libc-2.13.90.so
45f02000-45f05000 rw-p 00000000 00:00 0 
45f07000-45f0a000 r-xp 00000000 08:08 63924      /lib/libdl-2.13.90.so
45f0a000-45f0b000 r--p 00002000 08:08 63924      /lib/libdl-2.13.90.so
45f0b000-45f0c000 rw-p 00003000 08:08 63924      /lib/libdl-2.13.90.so
45f2b000-45f47000 r-xp 00000000 08:08 63954      /lib/libgcc_s-4.6.0-20110428.so.1
45f47000-45f48000 rw-p 0001b000 08:08 63954      /lib/libgcc_s-4.6.0-20110428.so.1
46b78000-46b94000 r-xp 00000000 08:08 49020      /lib/libtinfo.so.5.8
46b94000-46b97000 rw-p 0001b000 08:08 49020      /lib/libtinfo.so.5.8
b7386000-b7388000 rw-p 00000000 00:00 0 
b7388000-b73a7000 r--p 00000000 08:08 132967     /usr/share/locale/zh_CN/LC_MESSAGES/bash.mo
b73a7000-b73ae000 r--s 00000000 08:08 12004      /usr/lib/gconv/gconv-modules.cache
b73ae000-b7502000 r--p 0326f000 08:08 11676      /usr/lib/locale/locale-archive
b7502000-b7542000 r--p 02eb5000 08:08 11676      /usr/lib/locale/locale-archive
b7542000-b7742000 r--p 00000000 08:08 11676      /usr/lib/locale/locale-archive
b7742000-b7744000 rw-p 00000000 00:00 0 
b7764000-b7765000 rw-p 00000000 00:00 0 
bfc09000-bfc2a000 rw-p 00000000 00:00 0          [stack]

# 2  
Old 11-15-2011
There are small bits of any shared library which get altered slightly for each program it gets loaded in, to fix code offsets. So it's loaded in 'private' mode, where any changes that get set by your program are kept in RAM specific to that program.

This lets it share all the bits it doesn't change, but keep the bits it does change to itself. It's sort of like copy-on-write.
# 3  
Old 11-16-2011
But why the shared part of shared library don't show in the maps like
Code:
b73a7000-b73ae000 r--s 00000000 08:08 12004      /usr/lib/gconv/gconv-modules.cache

?
# 4  
Old 11-16-2011
Quote:
Originally Posted by vistastar
But why the shared part of shared library don't show in the maps like
Code:
b73a7000-b73ae000 r--s 00000000 08:08 12004      /usr/lib/gconv/gconv-modules.cache

?
shared libraries are mapped with MAP_PRIVATE flag (points the 'p') for only visible from the process which calls to mmap() not other process that mapping the same file.
if any changes are needed on the shared library, then changes just affect the memory mapped region of this process by the get a copy of this page and read/write on that.
so other process are not affected for any changes.

eventually these files are mapping with 'private' type for probably despite the case of file corruption.nevertheless after the any made changes (on the copy page), modified/changed pages can use for share between processes with MAP_SHARED flag.(as the `parent-child` processes..)

gconv-modules.cache is cache data (i.e..recently libraries..) file for speedup the loading executables that provided by glibc, therefore cache datas must use as writable for any applications.because, these are mapped with MAP_SHARED (points the 's').and so last changes are visible by the other processes.

regards
ygemici
# 5  
Old 11-16-2011
Than you, very useful.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Closing open file descriptors from /proc/pid/fd

Hi guys, i need to write a shell script that will close file descriptors from /proc/pid/fd will calling exec 4<&- solve the problem ? thanks in advance :) (15 Replies)
Discussion started by: alpha_romeo
15 Replies

2. Shell Programming and Scripting

does the pid of background process show in /proc?

Hi all, I'm reading <advanced bash scripting> and there is a example to kill a background process in a limited time,as shown below: #! /bin/bash #set -n TIMEOUT=$1 count=0 hanging_jobs & { while ((count < TIMEOUT));do eval ' && ((count = TIMEOUT))' ((count++)) sleep 1... (6 Replies)
Discussion started by: homeboy
6 Replies

3. UNIX for Dummies Questions & Answers

_/proc/stat vs /proc/uptime

Hi, I am trying to calculate the CPU Usage by getting the difference between the idle time reported by /proc/stat at 2 different intervals. Now the 4th entry in the first line of /proc/stat will give me the 'idle time'. But I also came across /proc/uptime that gives me 2 entries : 1st one as the... (0 Replies)
Discussion started by: coderd
0 Replies

4. UNIX for Dummies Questions & Answers

Need to get pid of a process and have to store the pid in a variable

Hi, I need to get the pid of a process and have to store the pid in a variable and i want to use this value(pid) of the variable for some process. Please can anyone tell me how to get the pid of a process and store it in a variable. please help me on this. Thanks in advance, Amudha (7 Replies)
Discussion started by: samudha
7 Replies

5. Red Hat

read maps from /proc/pid/

hi, i hav a query abt reading the contents of /proc/pid/maps file.is there any system apis or functions available to get the data from dat file and parse according to my need. i need name of the .so,Create date of the .so file.,Location of .so file etc. please provide a good source. yes i hav... (3 Replies)
Discussion started by: sanjaykhuntia
3 Replies

6. UNIX for Dummies Questions & Answers

Session PID & socket connection pid

1. If I use an software application(which connects to the database in the server) in my local pc, how many PID should be registered? Would there be PID for the session and another PID for socket connection? 2. I noticed (through netstat) that when I logged in using the my software application,... (1 Reply)
Discussion started by: pcx26
1 Replies

7. Programming

printing ppid,child pid,pid

question: for the below program i just printed the value for pid, child pid and parent pid why does it give me 6 values? i assume ppid is 28086 but can't figure out why there are 5 values printed instead of just two! can someone comment on that! #include<stdio.h> #define DIM 8 int... (3 Replies)
Discussion started by: a25khan
3 Replies

8. UNIX for Advanced & Expert Users

NIS Maps

Hello.. I stink at NIS! :) Im having a problem with NIS on solaris 2.X. / SPARC I have some maps that are exported to all clients in the domain. Now I setup a new server and add it as a nis client to the domain. On the NIS server there is a auto_direct map that mounts /usr/local . This is... (4 Replies)
Discussion started by: s93366
4 Replies
Login or Register to Ask a Question