c - Is all program code loaded into the text\code section\segment of memory -
i have started @ c programming , whilst not complete beginner (i have knowledge of java , web development) there lot of things not understand.
my question when program first loaded memory. having trouble understanding happens here.
is of program code loaded memory when program launched or needed loaded in?
after this code\set of instructions swapped in , out of physical disk process gets cpu time or loaded code stay in memory whilst program running?
if 2 processes can share same set of instructions mean each process gets separate code section in virtual memory space?
i sorry if questions basic or poorly worded started looking @ last week , after weekend of reading have far more questions answers!
is of program code loaded memory when program launched or needed loaded in?
most modern os's load "on demand", starting point of application (main) loaded os, os kicks off there. when application jumps piece of code isn't in memory yet, loads bit.
after this code\set of instructions swapped in , out of physical disk process gets cpu time or loaded code stay in memory whilst program running?
if os decides memory needed may throw out of code, , reload when needs later [if it's ever needed again - if part of initialization, may never hit again].
if 2 processes can share same set of instructions mean each process gets separate code section in virtual memory space?
it possible share code between multiple copies of same application. again, whether particular os or not depends on os. linux shares code copies same application between 2 (unrelated) processes [obviously, forked process shares code definition]. believe windows does.
shared libraries (".so" , ".dll" files linux/unix , windows respectively) used share code between processes - same shared library used many different applications.
the data space of course separate each application , shared libraries own data section per process sharing library.
Comments
Post a Comment