0
0
Operating Systemsknowledge~10 mins

Paging concept and page tables in Operating Systems - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Paging concept and page tables
Process wants memory
Divide memory into pages
Divide physical memory into frames
Page table maps pages to frames
CPU uses page table to find frame
Access physical memory frame
Return data to process
The process memory is split into pages, physical memory into frames, and a page table maps pages to frames so the CPU can find data.
Execution Sample
Operating Systems
Virtual Address: 0x1234
Page Size: 1KB (1024 bytes)
Page Number = Virtual Address / Page Size
Offset = Virtual Address % Page Size
Use Page Number to find Frame in Page Table
Physical Address = Frame * Page Size + Offset
This shows how a virtual address is translated to a physical address using page number, offset, and the page table.
Analysis Table
StepVirtual AddressPage NumberOffsetFrame Number (from Page Table)Physical Address CalculationPhysical Address
10x1234 (4660 decimal)4 (4660/1024=4)4660 % 1024 = 56477 * 1024 + 5647168 + 564 = 7732 (0x1E34)
20x0A00 (2560 decimal)2 (2560/1024=2)2560 % 1024 = 51233 * 1024 + 5123072 + 512 = 3584 (0x0E00)
30x1FFF (8191 decimal)7 (8191/1024=7)8191 % 1024 = 102311 * 1024 + 10231024 + 1023 = 2047 (0x07FF)
40x2000 (8192 decimal)8 (8192/1024=8)8192 % 1024 = 055 * 1024 + 05120 + 0 = 5120 (0x1400)
50x3000 (12288 decimal)12 (12288/1024=12)12288 % 1024 = 0Page not mappedNo frame foundPage fault - no physical address
6N/AN/AN/AN/AN/AStop - address not mapped
💡 Execution stops when a virtual page is not mapped in the page table, causing a page fault.
State Tracker
VariableStartAfter 1After 2After 3After 4After 5Final
Virtual AddressN/A0x12340x0A000x1FFF0x20000x3000N/A
Page NumberN/A427812N/A
OffsetN/A564512102300N/A
Frame NumberN/A7315N/AN/A
Physical AddressN/A7732358420475120Page faultN/A
Key Insights - 3 Insights
Why does the physical address sometimes not exist?
When the page number is not found in the page table (see step 5 in execution_table), it means the page is not loaded in physical memory, causing a page fault.
How is the offset calculated and why is it important?
Offset is the remainder after dividing the virtual address by page size (see execution_table column 'Offset'). It tells the exact byte inside the frame to access.
Why do we divide the virtual address by page size to get the page number?
Because memory is split into fixed-size pages, dividing gives which page the address belongs to (see execution_table column 'Page Number').
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3. What is the physical address calculated?
A7636 (0x1DBC)
B2047 (0x07FF)
C3584 (0x0E00)
D5120 (0x1400)
💡 Hint
Check the 'Physical Address' column in execution_table row for step 3.
At which step does the page fault occur because the page is not mapped?
AStep 2
BStep 4
CStep 5
DStep 1
💡 Hint
Look for 'Page not mapped' or 'Page fault' in the execution_table rows.
If the page size was doubled, how would the page number for virtual address 0x1234 change?
AIt would be half as large
BIt would stay the same
CIt would double
DIt would become zero
💡 Hint
Page number = Virtual Address / Page Size; increasing page size decreases page number.
Concept Snapshot
Paging splits virtual memory into fixed-size pages.
Physical memory is split into frames of the same size.
Page table maps each virtual page to a physical frame.
Virtual address = page number + offset.
CPU uses page table to find frame for a page.
If page not mapped, page fault occurs.
Full Transcript
Paging is a memory management method where virtual memory is divided into pages and physical memory into frames. Each virtual page is mapped to a physical frame using a page table. To find the physical address from a virtual address, the CPU divides the virtual address by the page size to get the page number and offset. It then looks up the frame number for that page in the page table. The physical address is calculated by multiplying the frame number by the page size and adding the offset. If the page is not mapped in the page table, a page fault occurs, stopping the process until the page is loaded. This method helps efficiently use memory and isolate processes.