paging techniques structure of the page tabletami/cop4610m12slides.pdfpractical problems of paging...
TRANSCRIPT
![Page 1: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/1.jpg)
Operating systemsModule 12
Main memory and
Virtual memory
Part 1
Paging techniques
Structure of the Page Table
1Tami Sorgente
![Page 2: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/2.jpg)
PAGING
2
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
0
1
2
3
4
5
6
7
Logical/virtual memory
pages
Page table
Frame #
Physical memory
frames
X
X
X
X
![Page 3: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/3.jpg)
PRACTICAL PROBLEMS OF PAGING
Each process must have its own page table –
page tables must reside in Memory –o much slower than registers – every time need to
address, have to go to page table – each instruction must then read memory once or twice – use special hardware for solution (TLB)
Page size? – fixed, but how big?
Small pages – mean many entries in tables
Big pages – internal fragmentation – memory waste
When page tables are very large then we have search problems
3Tami Sorgente
![Page 4: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/4.jpg)
TLB CACHING PAGE/ FRAME PAIRS
All gains require hardware support Solution: use cache with (page#, frame#) pairs-TLB (Translation look-aside buffer)
Find frame number in TLB – 20 ns
Find frame number in PT – 100 ns
Access memory– 100 ns
Effective Access Time (EAT) calculation:
80% hit ratio – 0.80x120 + 0.20x220 = 140 ns
40% overhead of paging
98% hit ratio –0.98x120 + 0.02x220 = 122 ns
22% overhead of paging
4Tami Sorgente
![Page 5: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/5.jpg)
ADDRESS TRANSLATION SCHEME Address generated by CPU is divided into:
o Page number (p) – used as an index into a page table which contains base address of each page in physical memory
o Page offset (d) – combined with base address to define the physical memory address that is sent to the memory unit
o For given logical address space 2m and page size 2n
o For given physical address space
5
page number page offset
p d
m - n n
f d
frame number frame offset
Tami Sorgente
![Page 6: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/6.jpg)
PAGING EXAMPLE
6
4 byte pages
00
00
01
10
11
0
1
2
3
a
b
c
d
01
00
01
10
11
4
5
6
7
e
f
g
h
10
00
01
10
11
8
9
10
11
i
j
k
l
11
00
01
10
11
12
13
14
15
m
n
o
p
0 5
1 6
2 1
3 2
Page table
Frame #
000
00
01
10
11
0
001
00
01
10
11
4 i
j
k
l
010
00
01
10
11
8 m
n
o
p
011
00
01
10
11
12
100
00
01
10
11
16
101
00
01
10
11
20 a
b
c
d
110
00
01
10
11
24 e
f
g
h
111
00
01
10
11
28
32 byte M
10 10
001 10
Logical address
of letter k
Physical address
of letter k
![Page 7: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/7.jpg)
Operating systemsModule 12
Virtual memory paging address translation
Part 2
7
![Page 8: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/8.jpg)
CONTENTS OF PAGE TABLE
Contents of Page Table:
Valid bit –if page is loaded (is in frame)
Frame number
modified bit -indicates if some part of the page has been written
referenced bit - if it has been referenced (victims)
protection bits –
8
frame #
valid bit – protection bits – modified (dirty) bit
1
0
write back to disk
no need to write
back (save time)
Tami Sorgente
![Page 9: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/9.jpg)
9
Size of virtual address (32 bits)Size of physical address (27 bits)
000 0000 0000 0010 1101 0110 1010
![Page 10: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/10.jpg)
PAGE FAULT
If there is a reference to a page, first reference to that page will trap to operating system:
page fault
1. Operating system looks at another table to decide:o Invalid reference aborto Just not in memory
2. Get empty frame3. Swap page into frame via scheduled disk
operation4. Reset tables to indicate page now in memory
Set validation bit = v5. Restart the instruction that caused the page fault
10Tami Sorgente
![Page 11: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/11.jpg)
STEPS IN HANDLING A PAGE FAULT
11Tami Sorgente
![Page 12: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/12.jpg)
Operating systemsModule 12
Virtual memory
Part 3
Page replacement
12Tami Sorgente
![Page 13: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/13.jpg)
VIRTUAL MEMORY REVIEW
Code needs to be in memory to execute,
but entire program rarely used
o Error code, unusual routines, large data
structures
Entire program not needed at same time
Ability to execute partially-loaded program
o Program no longer constrained by limits of
physical memory
o Programs could be larger than physical memory
13Tami Sorgente
![Page 14: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/14.jpg)
VIRTUAL MEMORY REVIEW
Virtual memory – separation of user logical memory from physical memoryo Only part of the program needs to be in memory for
execution
o Logical address space can therefore be much larger than physical address space
o Allows address spaces to be shared by several processes
o Allows for more efficient process creation
o More programs running concurrently
o Less I/O needed to load or swap processes
Virtual memory can be implemented via:o Demand paging
o Demand segmentation
14Tami Sorgente
![Page 15: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/15.jpg)
DEMAND PAGING
Bring a page into memory only when it is needed
o Less I/O needed, no unnecessary I/O
o Less memory needed
o Faster response
o More users
Page is needed reference to it
o invalid reference abort
o not-in-memory bring to memory
15Tami Sorgente
![Page 16: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/16.jpg)
ASPECTS OF DEMAND PAGING
Extreme case – start process with no pages in memoryo OS sets instruction pointer to first instruction of
process, non-memory-resident -> page fault
o And for every other process pages on first access
o Pure demand paging
Actually, a given instruction could access multiple pages -> multiple page faultso locality of reference
Hardware support needed for demand pagingo Page table with valid / invalid bit
o Secondary memory (swap device with swap space)
o Instruction restart
16Tami Sorgente
![Page 17: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/17.jpg)
BASIC PAGE REPLACEMENT
1. Find a free frame:- If there is a free frame, use it- If there is no free frame, use a page
replacement algorithm to select a victim page- Write victim page to disk if dirty
2. Bring the desired page into the (newly) free frame; update the page and frame tables
3. Continue the process by restarting the instruction that caused the trap
17Tami Sorgente
![Page 18: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/18.jpg)
PAGE REPLACEMENT
18Tami Sorgente
![Page 19: Paging techniques Structure of the Page Tabletami/COP4610M12Slides.pdfPRACTICAL PROBLEMS OF PAGING Each process must have its own page table – page tables must reside in Memory –](https://reader033.vdocument.in/reader033/viewer/2022042023/5e7bcdeb9ea2ec546341d22f/html5/thumbnails/19.jpg)
GLOBAL VS. LOCAL ALLOCATION
Global replacement – process selects a replacement frame from the set of all frames; one process can take a frame from another
o But then process execution time can vary greatly
o But greater throughput so more common
Local replacement – each process selects from only its own set of allocated frames
o More consistent per-process performance
o But possibly underutilized memory
19Tami Sorgente