I am recently studying the operating system, and I found the paging system a little bit confusing, for example, what will happen when there is a 52-bit virtual address and a 40-bit physical address, with 4KiB page size, so there are 2^40 pages and 2^28 frames, how pages are mapped in this case (the pages are more than frames) and how would the page table look like? Any help would be appreciated.
-
$\begingroup$ en.wikipedia.org/wiki/Virtual_memory#Paged_virtual_memory, en.wikipedia.org/wiki/Memory_paging $\endgroup$– Rinkesh PNov 30, 2022 at 8:59
-
1$\begingroup$ I suggest you refer standard textbooks of operating systems. Galvin a.k.a. dinosaur book is a good one. $\endgroup$– Rinkesh PNov 30, 2022 at 9:00
-
$\begingroup$ Thanks for the recommendation, I will check it out $\endgroup$– EricNov 30, 2022 at 15:59
1 Answer
Physical addresses refer to existing RAM memory. At any time, virtual pages can be mapped to physical pages (frames), or be swapped out on disk. Usually, just a subset of the virtual space is mapped (the rest being completely ignored by the process). That part is mapped to frames as long as they are available (possibly in competition with other processes). The rest is mapped to disk.
The mapping being quite dynamic, there is no particular relation between the virtual and physical addresses, and even less between their sizes. In theory, a single frame of RAM could be enough.
-
$\begingroup$ Do you mean the excess pages will not be mapped to the RAM memory but kept in the disk, when it is needed, other pages in the RAM will be swapped out (page replacement occurs), is that correct? If correct, what would the page table look like? Will there be some frames mapped by more than one page? $\endgroup$– EricNov 30, 2022 at 15:44
-
$\begingroup$ @Eric: A frame can be mapped to several pages in case of memory sharing between different processes. $\endgroup$– user16034Nov 30, 2022 at 16:24
-
$\begingroup$ So the page table will only map some pages to frames, if I want to calculate the size of the page table, it should be (frame number * entry size) instead of (page number * entry size), is that right? $\endgroup$– EricDec 1, 2022 at 5:39
-
$\begingroup$ @Eric: yes but the page table can also be paged. $\endgroup$– user16034Dec 1, 2022 at 8:32
-