Hi, there are a plenty of docs out there about virtual memory and such things... http://sophia.jpte.hu/linux/tlk/ especially http://sophia.jpte.hu/linux/tlk/node26.html could be of interest to you. There you can find some information on the linux kernel memory management. I think it quite funny, that the first thing, your application does on startup, is pagefaulting some times... :) Greetings Marcus Am Son, 2002-04-28 um 14.10 schrieb Al Riddoch: > On Sun, Apr 28, 2002 at 02:56:54PM +0200, Francesco Orsenigo wrote: > > How can I control which parts of my code are loaded in memory? > > In other terms, when the program needs to call a function (or a global > > variable?) this function is loaded with the all the symbols (functions and > > gvars) in the entire module (in my case, the .c file?) even if i don't need > > them? > > > > I'm splitting my program into many of .c files, so that functions that are > > used in a particular situations are grouped, kept apart from functions that > > must be used in other situations and can be unloaded... > > > > When you build your program, the concept of modules as .c or .o files > is essentially lost, and all the code is contained in the binary. Code > in shared libraries you use is handled differently, and for simplicity > I won't go into that here. > > On a modern Unix-like system, when you run the binary, its contents are > mapped into memory using the virtual memory subsystem. This means that > the contents of the file are not actually loaded, but a section of > the systems address space is set aside for your programs code. This > space is divided into pages, which were 4096 bytes on intel, but may > be larger on more recent CPUs. When the program needs to call some code, > the page containing that code is loaded into memory first, on a page > by page basis. > > I hope this gives you enough information to partly understand what goes > on. If you have any questions, feel free to ask. > > Al >
Dies ist ein digital signierter Nachrichtenteil