Reputation: 1
Multiple virtual addresses can map to a single physical address ----from Wikipedia.
if my base address of code segment and data segment at the same 0, the segments how to map to physical address?
Upvotes: 0
Views: 208
Reputation: 21
This is the concept of Virtual memory.
The user process is divided into many pages.
Even the main memory is divided into many frames such that the size of each frame is equal to the size of each page.
When a process is run, the entire program is not required but only some parts. So only those pages are loaded into the memory which are required at that instance of time. Later when they are not required, they are replaced by other pages.
Now this mapping of a page to the frame in the main memory is kept in a data structure called Page Table.
CPU always generates virtual address and the memory management unit translates this address to physical address using the page table.
Upvotes: 1
Reputation: 21607
Get segments out of your vocabulary.
Physical memory is divided into page frames. The size of a page frame varies amount systems but is usually between 512bytes and 4K bytes.
Each process has a logical address space consisting of an array of pages. The size of a page is the same as the size of a page frame.
Each process has a PAGE TABLE that contains mappings between logical pages and physical page frames.
Nothing (other than the operating system) prevents multiple page table entries from mapping to the same page frame.
Upvotes: 0