0

I have gone through with memory managment concepts of Operating system concept of Galvin , I have read a statment :

If you know at compile time where the process will reside in memory, then absolute code can be generated.

How at compile time processor got to know at which memory location in main memory process is going to store.

Can someone explain , what is the exactly does it means , if we know at compile time where process will reside in memory , As memory be allocated when program is moving from ready to running state .

2 Answers 2

1

Generally, machine code isn't position-independent. In order to be able to load it at an arbitrary starting address and run there one needs some extra information about the machine code (e.g. where it has addresses to the various parts of itself), so it can be adjusted to the arbitrary position.

OTOH, if the code is always going to be loaded at the same fixed address, you don't need any of that extra information and processing.

By absolute he means fixed + final, already adjusted to the appropriate address.

The processor does not "know" anything. You "tell" it.

0

I don't know exactly what he means with "absolute code", depending which operating system you use, the program with it's code and data will be loaded to a virtual address and executed from there.

Beside of this not the compiler but the linker sets the address where the program will be loaded to.

Modern operating systems like Linux are using Address Space Layout Randomization to avoid having one static address where every program is loaded and to avoid the possibility of exploiting software flaws.

If you're writing your own operating system maybe the osdev.org wiki could be a good ressource for you. If you can read/speak german I recommened lowlevel.eu either.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.