Docsity

Memory management virtual memory, Lecture notes of Database Programming

Toggle sidebar
bg1
Performance of Paging:
Main memory Access Time = 'm'○
Page Tables are stored in the main memory Th en the formula for
effective memory Access Time
E.M.A.T = 2m
○
The Translation look aside buffer (T.L.B) is adde d to improve the
performance of Paging
○
TLB is Hardware device Implementing using a ssociative Register
○
TLB contains frequently referenced Page num bers and
corresponding frame numbers
○
TLB Access Time will be very less compare to m ain memory Access
time
○
Translation Lookaside Buffer (TLB):
A special high-speed associative cache used by the Memory
Management Unit (MMU) to store recently us ed page table entries
(PTEs).
Purpose Speed up virtual-to-physical address translatio n in a paging →
system.
Why TLB is Needed
In paging, every memory access needs 2 steps :
Access page table (in main memory) to get fra me
number.
•
Access the actual memory location.•
•
This causes two memory accesses per instruct ion, slowing
execution.
•
TLB reduces this overhead by caching frequen tly used
page table entries.
•
TLB
Thursday, September 18, 20255:22 PM
KG GATE OS Page 1
Click to BUY NOW!
P
D
F
-
X
C
h
a
n
g
e
E
d
i
t
o
r
w
w
w
.
p
d
f
-
x
c
h
a
n
g
e
.
c
o
m
Click to BUY NOW!
P
D
F
-
X
C
h
a
n
g
e
E
d
i
t
o
r
w
w
w
.
p
d
f
-
x
c
h
a
n
g
e
.
c
o
m
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Memory management virtual memory and more Lecture notes Database Programming in PDF only on Docsity!

Performance of Paging:

○ Main memory Access Time = 'm'

Page Tables are stored in the main memory Then the formula for

effective memory Access Time

E.M.A.T = 2m

The Translation look aside buffer (T.L.B) is added to improve the

performance of Paging

○ TLB is Hardware device Implementing using associative Register

TLB contains frequently referenced Page numbers and

corresponding frame numbers

TLB Access Time will be very less compare to main memory Access

time

Translation Lookaside Buffer (TLB):

A special high-speed associative cache used by the Memory

Management Unit (MMU) to store recently used page table entries

(PTEs).

Purpose →Speed up virtual-to-physical address translation in a paging

system.

Why TLB is Needed

In paging, every memory access needs 2 steps:

Access page table (in main memory) to get frame

number.

  • Access the actual memory location.

This causes two memory accesses per instruction, slowing

execution.

TLB reduces this overhead by caching frequently used

page table entries.

TLB Thursday, September 18, 20255:22 PM Click to BUY NOW!

P^ D^ F

r w w w. p d f - x c h a n^ g^ e^. c^ o^ m^ Click to BUY NOW!

P^ D^ F

r w w w (^). (^) p d f - x c h a n^ g^ e^. c^ o^ m

  • TLB Access Time = 'c'
  • TLB Hit Ratio = 'x'

Then the formula for effective memory Access Time

E.M.A.T = x(c + m) + (1 - x)(c + 2m)

Q. A system has the following specifications:

  • Main memory access time = 100 ns
  • TLB access time = 20 ns
  • TLB hit ratio = 95%

What will be the Effective Memory Access Time (EMAT) with TLB?

A) 120 ns

B) 115 ns

C) 110 ns

D) 125 ns

Click to BUY NOW!

P^ D^ F

r w w w. p d f - x c h a n^ g^ e^. c^ o^ m^ Click to BUY NOW!

P^ D^ F

r w w w (^). (^) p d f - x c h a n^ g^ e^. c^ o^ m

Q.A computer system uses two-level paging.

  • Memory access time = 100 ns
  • TLB access time = 20 ns
  • TLB hit ratio = 90%

What is the Effective Memory Access Time (EMAT)?

A) 120 ns

B) 200 ns

C) 140 ns

D) 320 ns

Q. A paging scheme uses a Translation Look-aside Buffer (TLB). A TLB-access

takes 10 ns and the main memory access takes 50 ns. What is the effective

access time(in ns) if the TLB hit ratio is 90% and there is no page-fault? (GATE

(a) 54

(b) 60

(c) 65

(d) 75

Q. Consider a paging hardware with a TLB. Assume that the entire page table and

all the pages are in the physical memory. It takes 10 milliseconds to search the TLB

and 80 milliseconds to access the physical memory. If the TLB hit ratio is 0.6, the

effective memory access time (in milliseconds) is _________. (GATE-2014)

Click to BUY NOW!

P^ D^ F

r w w w. p d f - x c h a n^ g^ e^. c^ o^ m^ Click to BUY NOW!

P^ D^ F

r w w w (^). (^) p d f - x c h a n^ g^ e^. c^ o^ m

Inverted Page Table (IPT) : -

An Inverted Page Table (IPT) is a type of page table where the number of entries is equal to the

number of physical frames in memory, not the number of virtual pages.

This reduces memory overhead compared to conventional page tables (especially in large virtual

address spaces).

1. Inverted Page Table is an alternative to conventional page table.

2. Here, one entry per physical frame is kept (not per virtual page).

Each entry stores:

○ Process ID (PID)

○ Virtual Page Number (VPN)

○ Control bits (valid, protection, reference, dirty, etc.)

4. The index of the table itself represents the frame number.

5. Address translation requires searching the table for (PID, VPN).

Inverted Paging Friday, September 19, 2025 3:55 PM Click to BUY NOW!

P^ D^ F

r w w w. p d f - x c h a n^ g^ e^. c^ o^ m^ Click to BUY NOW!

P^ D^ F

r w w w (^). (^) p d f - x c h a n^ g^ e^. c^ o^ m

Q2. A computer has a 32-bit virtual address and 512 MB physical memory.Page size = 8 KB.

How many entries will be present in the Inverted Page Table?

A) 2^17

B) 2^16

C) 2^20

D) 2^27

Click to BUY NOW!

P^ D^ F

r w w w. p d f - x c h a n^ g^ e^. c^ o^ m^ Click to BUY NOW!

P^ D^ F

r w w w (^). (^) p d f - x c h a n^ g^ e^. c^ o^ m

Demand Paging : - Demand Paging is when a page is brought into main memory only when

the CPU tries to access that page, causing a page fault if it is not already in memory.

Only required pages are loaded.

Reduces memory usage and allows more processes to fit in memory.

Virtual Memory : - Virtual Memory is a technique that allows a computer to use more memory

than the physical RAM by temporarily storing parts of a program on disk.

Programs can be larger than physical memory.

Only the needed parts of a program are kept in RAM; the rest stays on disk.

Virtual memory is implemented using demand paging, where pages are loaded into main

memory only when they are needed.

Virtual Memory Friday, September 19, 2025 5:34 PM Click to BUY NOW!

P^ D^ F

r w w w. p d f - x c h a n^ g^ e^. c^ o^ m^ Click to BUY NOW!

P^ D^ F

r w w w (^). (^) p d f - x c h a n^ g^ e^. c^ o^ m

Page Replacement Algorithm : - Page replacement algorithms are used when a page fault

occurs and there is no free frame in memory. The algorithm decides which page to

remove from memory to bring the required page.

Goal:

Minimize the number of page faults.

Improve overall system performance.

FIFO (First-In, First-Out)

• The page that has been in memory the longest is replaced.

• Easy to implement using a queue.

Disadvantage: Can suffer from Belady’s anomaly (more frames can cause

more faults).

LRU (Least Recently Used)

• Replace the page that has not been used for the longest time.

• Approximates the optimal algorithm.

• Needs hardware support or counters to track usage.

Optimal (MIN)

• Replace the page that will not be used for the longest time in the future.

Theoretical best algorithm (minimizes page faults).

• Not implementable in practice (needs future knowledge).

MRU (Most Recently Used) Page Replacement

• Replace the page that was most recently accessed.

The logic is opposite of LRU. It assumes that the page that was just used is

more likely to be used again only after a long time, so it is safe to remove it

now.

Q. Consider the following reference string:

Number of frames = 3

Find the number of page faults for the following page replacement algorithms:

1. FIFO

2. Optimal

3. LRU

4. MRU

Page Replacement Algorithm

Friday, September 19, 2025 6:14 PM Click to BUY NOW!

P^ D^ F

r w w w. p d f - x c h a n^ g^ e^. c^ o^ m^ Click to BUY NOW!

P^ D^ F

r w w w (^). (^) p d f - x c h a n^ g^ e^. c^ o^ m

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0 , 1, 7, 0, 1 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0 , 1, 7, 0, 1 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0 , 1, 7, 0, 1 Click to BUY NOW!

P^ D^ F

r w w w. p d f - x c h a n^ g^ e^. c^ o^ m^ Click to BUY NOW!

P^ D^ F

r w w w (^). (^) p d f - x c h a n^ g^ e^. c^ o^ m

Segmentation: -

  1. Paging does not follow the user’s view of memory allocation. To achieve the user’s view of memory allocation, the concept of segmentation is implemented.
  2. In segmentation, the Logical Address Space (LAS) is divided into various segments.
  3. Segments of the LAS are brought into the Physical Address Space (PAS).
  4. Segments of the LAS can vary in size.
  5. S = Number of bits required to represent the segment number of the LAS. d = Number of bits required to represent the word number within a segment (i.e., segment offset).
  6. The number of entries in the segment table is the same as the number of segments in the LAS.
  7. The variable-sized segments are brought from LAS to PAS, so segmentation behaves similarly to a variable partitioning scheme; hence, it still suffers from external fragmentation.

Segmentation Thursday, September 25, 2025 4:13 PM Click to BUY NOW!

P^ D^ F

r w w w. p d f - x c h a n^ g^ e^. c^ o^ m^ Click to BUY NOW!

P^ D^ F

r w w w (^). (^) p d f - x c h a n^ g^ e^. c^ o^ m

Segmentation with Paging : -

Since segmentation also suffers from external fragmentation, it is better to divide the

segments into pages as the segments size increases.

In segmentation with paging scheme a process is divided into segments and further

the segments are divided into pages.

One can argue it is segmentation with paging is quite similar to multilevel paging, but

actually it is better, because here when page table is divided the size of partition can

be different (as actually the size of different chapters can be different).

Segmentation with Paging Wednesday, January 21, 2026 7:08 PM

Click to BUY NOW!

P^ D^ F

r w w w. p d f - x c h a n^ g^ e^. c^ o^ m^ Click to BUY NOW!

P^ D^ F

r w w w (^). (^) p d f - x c h a n^ g^ e^. c^ o^ m