16. What is the relationship between Page Table Entry, and page in/out, swapping in the operating system?

What is the relationship between Page Table Entry, and page in/out, swapping in the operating system?

I write about a more complete description of PTE’s(Page Table Entry) internal structure. I believe this will be extremely beneficial to students and scholars, and inquiries are always welcome.

What is the subject of this article?

  • PTE internal structure
  • How are page tables filled?
  • Multilevel page table

PTE internal structure

Inside the Page Table Entry, there are more complex pieces of information to map virtual memory pages and actual memory pages.

valid bit (present bit)dirty bitaccess bitPF#

If the valid bit is set to 0, it indicates that the page frame (PF#) indicated by the current PTE does not exist. If the valid bit is 1, it indicates that the page frame exists. The dirty bit, also known as the modified bit, indicates that the content of the page referenced by the current PTE has been altered. The Access bit specifies whether or not the content of the current page frame may be read. The frame pointed to by the PTE is denoted by PF#.

Page out refers to preserving the contents of a page frame that is now being used to swap space and then passing that page frame to another application that requires it. Paging, on the other hand, refers to loading the contents of swap area back into memory and giving a page frame. When there is a lack of physical memory page frames, the contents of one page frame will be saved in swap space, same as when an elevator is overcrowded and one person needs to exit. It will be investigated later how the page frame to be paged out will be decided by some criterion – if the dirty bit will be set.

What is the relationship between Page Table Entry, and page in/out, swapping  in the operating system? (Page in, Page out)
Page in, Page out

Every detail of where the contents of each page frame of a program are now situated is critical. When referring the information, these bits of information must remain within the PTE for the process to swiftly execute a command. Just as having information about the contents of a page frame in swap space aids for quicker loading (page in) when the contents of a page frame are needed again. The material that has been paged out, on the other hand, does not have to enter the same page frame when it is paged in. The PTE contains all of the modifications.

A more in-depth description of Swapping is required here. What will happen if the system runs out of memory? Memory processes with low consumption frequency are sent out, and if memory is deemed to be significantly inadequate, the entire application is transferred to swap space. Swapping out means sending the program from memory to swap space all at once. When the application is resumed after being swapped out, it will take some time for it to be loaded back into memory. The reason a window that we did not use in the Windows environment takes so long to open after clicking it is not because the machine is old, but because the application has been swapped out in memory.

So what is the cause of page out?
We already know that not all presently executing applications are completely executed in memory. Demand paging refers to a paging mechanism in which one application maps page frames as needed within itself. It indicates that paging occurs only when a page is requested. A free page that is not being occupied by another program is necessary to swiftly map a program every time it starts. Page out happens when there aren’t enough free pages. In other words, by obtaining free pages via page out, you may avoid mapping delays caused by a lack of page frames. The complicated information in the PTE, as well as the necessity for a page out, are both due to the fact that the program must execute in real memory, which has considerably less capacity than virtual memory, where the program is loaded.

Will all page contents be paged out? The system might stop if a function that the whole system needs is paged out. That’s an excellent point. As a result, pages are often fixed (page fixed) to avoid being paged out. Pages are fixed when a function is required by the entire system, such as the kernel area and sections where input and output are in operation. When the contents are paged out, where are they saved? To be honest, we don’t know. The swap space manager is a piece of hardware that manages and relocates swap space and page frames. Second storage, such as hard drives, is typically used for swap space.

So, swap out only occurs when memory is entirely depleted? The system will cease if a suitable amount of memory is not secured once the memory is drained. A system designer who disables the system is the most likely candidate for dignified retirement. When there is less memory than the swap threshold standard, swap out is conducted. The swap threshold is established when the system functions without interruption and memory may be safeguarded. Page out, as previously stated, does not wait until the free page is spent. Page out is conducted when a specified baseline or page threshold is reached to avoid the system from terminating due to a shortage of free pages. It’s akin to a country with low foreign reserves desperately trying to get foreign currency while incurring significant economic losses.

How are page tables filled?

When a program is first executed, the page table is empty. A page fault occurs when there is nothing in the page table, indicating that the page frame being accessed by the program is not in memory. In this case, a free page is chosen and a PTE containing the page frame number is generated. When a new student transfers to a school, their name is not placed into the attendance book. Using the student’s old school profile, the homeroom teacher fills in the blank space in the attendance book. Users are misled into believing that a program is continually performed while, in fact, it is separated and executed on a page-by-page basis. The OS promptly scans the swap file in anticipation of such deceit. There was space and a temporarily unused page frame. While in operation, the system works continuously. It would take a superb system designer to develop such a clever operating system.

We’ve already discussed what page tables are and what role they perform. One thing is obvious in our minds: they are extremely intricate. Because of the system’s intricacy, a large amount of memory is consumed inside. The Excel application, which we use for computations, is 21MB in size, while MS-WORD is roughly 18MB. The majority of programs have significantly lower capacity. When you consider that the page table consumes 4MB of RAM, it’s not a little file.

Calculation of page table size
1 page size = 4KB
Computer address space size = 4GB when
4G/4K = 1MB × 4 bytes (pte size)
= 4MB (page table size)

Even though the page table is enormous, if each table item is used efficiently, there will be no difficulty. Wasteful components are present. A 32-bit address bus CPU has 2^20 entry items (an huge total of 1,048,576 when computed), however for a 1MB application, only roughly 250 (1MB/4KB) of the actual page table entries in use would be required. In other words, the majority of page table items are just placeholders with no content. The multi-layer page table was created as a result of thinking about how the page table wastefully uses memory.

Multilevel page table

To work more effectively, the multi-layer page table creates just the page table entries that are required. When necessary, a 4KB (1024 item) page table the same size as the page frame is built. To do this, the address of the page table must be determined in two phases. The page directory, which contains the addresses of the current necessary page table entries, is kept in the level 1 table. The level 2 table then creates a page table using only the current page frame numbers. For most programs, two or three level 2 page tables are adequate. In other words, despite using the same application, just 1,048,576 page table entries are required, the same as when building a plain page table.

What is the relationship between Page Table Entry, and page in/out, swapping  in the operating system? (Multilevel Page Table)
Multilevel Page Table

Key Points Synopsis

What exactly is page out? Page out is the process of storing the contents of a page frame that is presently being used to swap space and passing it on to another application that requires it. Page in, on the other hand, is the act of loading stuff from swap area back into memory and creating a page frame. When a program is executed, it requires a free page that is not being taken by another program in order to swiftly map the program. Page out happens when there aren’t enough free pages.

What exactly is swap out? If the system’s memory is low, a program is swapped out and transmitted from memory to swap space all at once.

What exactly is a page fault? When the page frame that the software is seeking to access is not in memory, a page fault occurs. In this situation, a free page is gained, and a PTE with the page frame number is formed.

A multi-layer page table is what it sounds like. A multilayer page table generates just the page table entries that are required. The level 1 table stores the page directory as well as the addresses of the current required page table entries. As a result, the level 2 table creates a page table that simply contains the current page frame numbers.


All Links for Operating System
1. Before You Begin with Operating Systems
2. What is the history of operating systems and specifically what tasks do they perform?
3. Will the missions and tasks of operating systems expand in the future?
4. Basic Concepts Needed to Understand Operating Systems
5. About Operating System Process Life Cycle
6. How is Operating System Process Management done?
7. How can we increase the processing speed of operating system processes?
8. What is an Operating System Thread?
9. How does Operating System Scheduling work?
10. Is there a criterion for comparing OS Scheduling Algorithms?
11. What is Process Synchronization in OS?
12. What is a Semaphore in Operating Systems?
13. (Memory Management) How do you manage operating system memory?
14. How is the OS Memory Partitioned?
15. What is OS Virtual Memory?
16. What is the relationship between Page Table Entry, and page in/out, swapping in the operating system?
17. What are the basic concepts of OS memory?
18. Operating System Page Replacement Algorithm
19. About Operating System File Systems
20. What is the internal structure of the file system in the operating system?
21. OS disk space allocation techniques and effective algorithm criteria?
22. What is Access time, Disk scheduling algorithm, and I/O system in the OS file system?
23. Types and Understandings of Operating System Architecture

Leave a Comment