Linear/Relative Address and Paging Address mapping

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
green1
Posts: 5
Joined: Fri Apr 18, 2014 5:29 am

Linear/Relative Address and Paging Address mapping

Post by green1 »

Hi Folks,

Currently I am studying memory management scheme in the operating system. First we studied relative address that during the load time the loader basically put the relative addressing in the program then at the run time or the execution time it is the job of the linker to link that
physical address by adding the base register but this is the case of contigious memory location. Now lets come to the concept of paging. Lets suppose the paging is involved. The loader again loads the program in the memory but this time each bytes are loaded they are recorded
in the page table with the page number with the respect to limit such as the page size is 4KB so first 4 KB in page 1 next 4 KB in page 2. Address now calculated is corresponding to the page number and offset however the address present in the instruction was the relative
address. Now here I am confused, How that linear address or relative address is changed into the page format address (Page Index + displacement). Whose job is to make that happened. I have made an equation by my own :) but I am not satisfied. The equation is as given below
v (p,d) where p is the page index and the d is the displacement. Now if the relative address is lets suppose 751th byte to jump on then the page index would be p = x1/y1 where x1 is the 751 and y1 would be the page size lets say 4 and it would give the page index number. Now if we
want to calculate the displacement it would be d = ((p -1) x y) - x1. So the final address would be 188th page and d would be 3. I know this sounds crazy, But please shed some light on it
azblue
Member
Member
Posts: 147
Joined: Sat Feb 27, 2010 8:55 pm

Re: Linear/Relative Address and Paging Address mapping

Post by azblue »

green1 wrote: Now here I am confused, How that linear address or relative address is changed into the page format address (Page Index + displacement). Whose job is to make that happened. I have made an equation by my own :) but I am not satisfied. The equation is as given below
Let the CPU do it
green1 wrote: Lets suppose the paging is involved. The loader again loads the program in the memory but this time each bytes are loaded they are recorded
in the page table with the page number with the respect to limit such as the page size is 4KB so first 4 KB in page 1 next 4 KB in page 2.
First figure out how many pages you need; for example, if you're loading 40KB, you need 10 pages. Set up the page tables so that you have 10 contiguous pages in virtual space, then just load your file; you don't need to worry about what byte is falling on what page.
green1
Posts: 5
Joined: Fri Apr 18, 2014 5:29 am

Re: Linear/Relative Address and Paging Address mapping

Post by green1 »

Dear,

Thanks for your reply. But I am not doing any practical example. All I am studying the theoretical work. Therefore I need an understanding for that. It would be very nice, if you can guide me in this way. Thanks


BR
Post Reply