Co2 - Special Class
Co2 - Special Class
Dis-Advantages Of Paging
• May cause Internal fragmentation
• Page tables consume additional memory.
• Multi-level paging may lead to memory reference overhead.
Example: A Simple Paging
• 128-byte physical memory with 16 bytes page frames
• 64-byte address space with 16 bytes pages
0 re s e rv e d fo r O S
page frame 0 of
reserved for OS physical
16 (u n u se d )
memory
(unused) page frame 1
32
0
(page 0 of page 3 of AS page frame 2
16 the address 48
space)
(page 1) page 0 of AS page frame 3
32 64 (u n u se d )
(page 2)
(unused) page frame 4
48
80
(page 3)
64 page 2 of AS page frame 5
96
A Simple 64-byte Address Space
(u n u se d )
0 1 0 1 0 1
0 1 0 1 0 1
12
Example: Address Translation
• The virtual address 21 in 64-byte address space
VPN offset
0 1 0 1 0 1
Virtual
0 1 0 1 0 1
Address
Address
Translation
Address
Translation
1 1 0 1 0 1
1
Physical
1 1 1 0 1 0 1
Address
PFN offset
13
Paging Segmentation
1. In Paging Scheme, the main
memory is partitioned into 1. In Segmentation scheme, the
frames(or blocks). main memory is partitioned into
segments.
2. The logical address space is
divided into pages by the 2. The logical address space is
compiler or memory divided into segments as
management unit (MMU) specified by the programmer.
3. This Scheme suffer from 3. This scheme suffers from
internal Fragmentation or Page external fragmentation.
Breaks. 4. The OS maintains the particulars
4. The OS maintains a free frame of available memory.
list; there is no need to search
for free frame.
Paging Segmentation
Logical TLB
Address Lookup MMU TLB Hit Physical
TLB Address
popular v to p
TLB Miss
Page 0
CPU Page Table
Page 1
all v to p entries
Page 2
…
Page n
Address Translation with MMU
Physical Memory
size: 100
8 bytes header m a g ic : 1 2 3 4 5 6 7
magic: 1234567
■ ■ ■
s iz e : 100
m a g ic : 1 2 3 4 5 6 7
size: 100
magic: 1234567
sptr
100 bytes still allocated
■■■
■ ■ ■
m a g ic : 1 2 3 4 5 6 7
size: 100
magic: 1234567
■ ■ ■
head s iz e : 3764
n e x t: 0
size: 3764
next: 0
■ ■ ■
m a g ic : 1 2 3 4 5 6 7
size: 100
magic: 1234567
■ ■ ■
100 bytes still allocated
free list. head s iz e : 100
size: 100
• The free list will start with a small
n e x t: 16708
next: 16708
sptr
chunk. ■■■
■ ■ ■
(now a free chunk of
memory)
• The list header will point the small chunk s iz e : 100
size: 100
• The free() function is used to m a g ic : 1 2 3 4 5 6 7
magic: 1234567
deallocate memory while it is ■■■
size: 3764
syntax of the free is simple. We
n e x t: 0
next: 0
So, total number of page faults = 9. Given memory capacity (as number of pages it can
hold) and a string representing pages to be referred, write a function to find number of
page faults.
Optimal Page Replacement Algorithm
The Optimal Page Replacement algorithm has the lowest page fault
rate of all algorithms. The criteria of this algorithm is “ Replace a
page that will not be used for the longest period of time”
(The Longest Time in Feature)
LRU Page Replacement Algorithms