Click to See Complete Forum and Search --> : for every program, does the stack begins with the same virtual address ?
nirVaan
May 19th, 2008, 12:22 AM
hi this is more to do with computer architecture but i hope i can find a answer here.
the question is for every program, Does the individual stacks begins with the same virtual address ?
if this is so does this mean
in program A
int main()
{
int x;
return 0;
}
the variable x
and in program B
int main()
{
int y;
return 0;
}
the variable y will have the same virtual address if they are executed in the same machine (because the two programs are more or less the same)
thankz
olivthill
May 19th, 2008, 07:39 AM
The stacks are different for each program (unless the two programs are running in the same memory space and the programmer loads the stack register with the same address in both program, which would be a very exceptional case).
nirVaan
May 19th, 2008, 09:37 PM
ahhh i should have mentioned that im talking about linux.i have seen in various books thats says in many unix systems,programs stacks have the same virtual address if they are run on the same machine. for intance fedora seems to have this address 0xfe000000
and this what a certain book said
"Note that on many Linux distributions, the stack is located in high memory
addresses, with its top just a bit below 0xc0000000. On Fedora systems, this
number is different—0xfe000000. On Windows, this is different because
memory setup is more complex in general. For example, processes can have
many heaps, and each DLL its own heap and stack, but the most important dif-
ference is that stack position is not really fixed ........"
this implies that in linux systems the stack starting address is fixed (virtual address of course) while in windows isnt ?????
TheCPUWizard
May 19th, 2008, 09:40 PM
In general, if multiple programs (even radically different ones) are build against the same runtime environment, then they stack will be initialized to the same virtual address. Of course the PHYSICAL address will be different.
nirVaan
May 20th, 2008, 01:28 AM
thankz
is this a feature of the compilers that are used today or is this a prerequisite of some of the runtime environments ( may be a prerequisite of its memory manager)
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.