Memory allocations in linux for processes

Valdis.Kletnieks at vt.edu Valdis.Kletnieks at vt.edu
Tue Mar 19 12:18:54 EDT 2013


On Tue, 19 Mar 2013 20:41:55 +0530, Niroj Pokhrel said:

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

Unless you linked it statically, a lot of stuff happens before you ever
get to main() - namely, any shared library linking and mapping.  Run
strace on your binary and see how many system calls happen before you hit
the infinite loop.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130319/69fc4c6b/attachment.bin 


More information about the Kernelnewbies mailing list