Documente Academic
Documente Profesional
Documente Cultură
System Organization
Main Memory
Virtual Memory
Translation Lookaside Buffer
Acknowledgement
Slides from previous CS433 semesters
TLB figures taken from
http://www.cs.binghamton.edu/~kang/cs350/Chap
Paging
Segmentation + Paging
Segmentation
Supports user view of memory.
Virtual memory is divided into variable
length regions called segments
Virtual address consists of a segment
number and a segment offset
<segment-number, offset>
Fragmentation
Memory allocation is a dynamic process that
uses a best fit or first fit algorithm
Fragmentation is NOT segmentation
External
Internal
Data
Internal vs External
External fragmentation:
free space divided into many small pieces
result of allocating and deallocating pieces of the storage
space of many different sizes
one may have plenty of free space, it may not be able to all
used, or at least used as efficiently as one would like to
Unused portion of main memory
Internal fragmentation:
result of reserving a piece of space without ever intending
to use it
Unused portion of page
Paging
Virtualmemory is divided into fixed-size
blocks called pages
typically a few kilobytes
should be a natural unit of transfer to/from disk
Page replacement
LRU, MRU, Clock… etc
Page placement
Fully associative - efficient
Paging
Page Identification
Virtual address is divided into
<virtual page number, page offset>
The virtual page number is translated into a
physical page number
Provides indirection
Indirection is always good
Translation cached in a buffer
Paging vs Segmentation
Paging: Segmentation:
Block replacement easy Block replacement hard
Fixed-length blocks Variable-length blocks
Need to find
contiguous, variable-
sized, unused part of
main memory
Paging vs Segmentation
Paging: Segmentation:
Invisible to application Visible to application
programmer programmer
No external fragmentation No internal fragmentation
There is internal Unused pieces of main
fragmentation memory
Unused portion of page There is external
Units of code and data are fragmentation
broken up into separate Keeps blocks of code or
pages data as single units
Segmentation + Paging
Segmentation is typically combined with
paging
Paging is transparent to the programmer
Segmentation is visible to the programmer
Each virtual memory reference can cause two physical memory accesses
One to fetch the page table
One to fetch the data
Page Table
TLB is a cache
Fully associative for efficiency
TLB
Given a virtual address, processor examines
the TLB
If page table entry is present (TLB hit)
the frame number is retrieved and the real
address is formed
TLB
Ifpage table entry is not found in the TLB
(TLB miss)
Hardware checks page table and loads new Page
Table Entry into TLB
Hardware traps to OS, up to OS to decide what to
do
OS knows which program caused the TLB fault
the software handler will get the address mapping
TLB Miss
If page is in main memory (page hit)
If the mapping is in page table, we add the entry
to the TLB, evicting an old entry from the TLB
TLB
If page is on disk (page fault)
load the page off the disk into a free block of
memory
update the process's page table
TLB
TLB