321 views
2 votes
2 votes
I want to know if we are swapping the page from mainmemory to harddisk will the page go and sit in the same location in the harddisk where it initially is loaded from

1 Answer

2 votes
2 votes

No , there isn't anything like 'page go to disk' , we use this kind of words just to logically understand the problem.

I'm creating a general scenario here , what actually happens. Initially let suppose there is some process P , whose image is in hard disk(of course in executable form) and now this process wants to execute and so during load time it's executable image is linked with virtual address space(VAS is generated by CPU)now suppose we're working with run time binding so here MMU comes into picture , to translate VA(virtual address) to PA(physical address)for faster response MMU manages h/w cache (TLB)  if it find the entry in TLB , you will get your physical address and then perform your wished task , if there is no respective entry in TLB , MMU will find the respective Page Table location from PTBR(page table base register) and access the page table , if there is a valid entry for desired page, fine otherwise there will a page fault generated by CPU , now MMU OS comes into picture , it will load the disk image and write it to some free frame , if there is no free frame available , the some page replacement algorithm will select appropriate frame to move out to disk , so that there can be free space.

Now come to your question , when page replacement algorithm select some page to move out , it's not like page go to disk...OS will simply update  the PTE of that process(whose frame is selected to move out)to invalid , because now there is no mapping for that page to some physical memory frame. now OS created free frame so the desired disk image is copied to this frame and here also then respective PTE is updated.

i wrote this in just juicy way , although the whole process is architecture dependent and more sophisticated. if you think somewhere i went wrong tell me.

you can read about it more here

https://www.kernel.org/doc/gorman/html/understand/understand006.html#toc19

https://www.kernel.org/doc/gorman/html/understand/understand014.html#toc74

Related questions

0 votes
0 votes
0 answers
1
SSR17 asked Feb 8
206 views
we have 8 pages (each side 32B) to store in physical memory of 2^32 bits how many bits are required to identify each page , according to me 3 bits are required but that i...
0 votes
0 votes
2 answers
4
Unique_999 asked Aug 17, 2023
319 views
Can Any explain the relationship between The “ Word Size “ and “ Logical Address Space “