Memory allocations in linux for processes
Niroj Pokhrel
nirojpokhrel at gmail.com
Tue Mar 19 11:11:55 EDT 2013
On Tue, Mar 19, 2013 at 8:27 PM, Mulyadi Santosa
<mulyadi.santosa at gmail.com>wrote:
> Hi Niroj....
>
> Please see inlined answer below...
>
> On Mon, Mar 18, 2013 at 5:28 PM, Niroj Pokhrel <nirojpokhrel at gmail.com>
> wrote:
> > Hi all,
> > As I have read, whenever we execute a program, the memory is allocated in
> > different sections viz stack, text and data segment.
>
> Yup, that is correct
>
> > But, since we have used
> > loader and linker the three allocations will happen for them too.
>
> Correct again. Linker and loader will be the part of process address space.
>
> > But when I ran a program and did pmap pid, I saw several other fields
> which
> > I have no idea of. What is the [anon] and what is it doing here ?
>
> Anon is short of anonymous. It is a region of memory created by
> function e.g malloc() or mmap()
>
> >Why the
> > memory is being implemented for it and there are so many of them ?
>
> Drawing from above explanation, we can easily conclude somewhere in
> the program, it does malloc() or mmap().
>
> > And also the stack ( 3rd last element), is it the process stack??
>
> Yes, it's process' stack
>
> >Can
> > somebody please explain.
> > Thanking you all in advance.
> >
> > 5448: ./a.out
> > 0000000000400000 4K r-x-- /home/n.pokhrel/Personal/mywork/a.out
> > 0000000000600000 4K r---- /home/n.pokhrel/Personal/mywork/a.out
> > 0000000000601000 4K rw--- /home/n.pokhrel/Personal/mywork/a.out
> > 00007f57f5e18000 1512K r-x-- /lib/libc-2.11.1.so
> > 00007f57f5f92000 2044K ----- /lib/libc-2.11.1.so
> > 00007f57f6191000 16K r---- /lib/libc-2.11.1.so
> > 00007f57f6195000 4K rw--- /lib/libc-2.11.1.so
> > 00007f57f6196000 20K rw--- [ anon ]
> > 00007f57f619b000 128K r-x-- /lib/ld-2.11.1.so
> > 00007f57f6396000 12K rw--- [ anon ]
> > 00007f57f63b8000 8K rw--- [ anon ]
> > 00007f57f63ba000 4K r---- /lib/ld-2.11.1.so
> > 00007f57f63bb000 4K rw--- /lib/ld-2.11.1.so
> > 00007f57f63bc000 4K rw--- [ anon ]
> > 00007fffa2f37000 84K rw--- [ stack ]
>
> > 00007fffa2fa0000 4K r-x-- [ anon ]
> > ffffffffff600000 4K r-x-- [ anon ]
>
> ok, one of the region above, I think it's VDSO (virtual dynamic shared
> object). It's a region that handle system call. When a process does
> system call, it jumps to VDSO, and it is the VDSO that does the
> actuall syscall
>
> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
>
Hi Mulyadi .
Thank you very much.... But I still have a minor confusion .........
All I ran was this short program
#include<stdio.h>
int main()
{
while(1)
{
}
return 0;
}
I don't understand where does mmap or malloc come in to play in this code.
It would be great if you can give me some insight.
Thanking you in advance.
Yours,
Niroj Pokhrel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130319/cff69807/attachment.html
More information about the Kernelnewbies
mailing list