Reputation: 7719
In "Operating Systems Concepts" book of Silberchatz , it says
"Shared code must appear in same location in the logical address space of all processes" ,
Why does it have to appear in same location ? I thought that for each process we have a separate Page table , which makes it possible to have share code address in different logical addresses !
Upvotes: 1
Views: 915
Reputation: 66
every address, like jump-to addresses, used in the library (shared code) is fixed pointing to the specific logical address. Therefore, those logical addresses shall be the same in all processes that have imported this library. It means that you could only place this library in the exact same logical address to let the library find its own code
Upvotes: 0
Reputation: 62058
Machine code is rarely fully position-independent. If you have some code that's been compiled to work when located at address 0x10000 (logical/virtual) and you move it to address 0x70000 (logical/virtual), it won't work at the new location.
Page tables can't help with this. What can is code/data addressing modes relative to the instruction pointer
(AKA program counter
). Some CPUs have it, some don't have it, yet some others have it half-baked (e.g. they can have it only for instructions that transfer control (e.g. jump
/call
) to other places in code, but nothing for data (e.g. move
)).
Upvotes: 2