Professional Documents
Culture Documents
❯ The virtual memory technique allows users to use more memory for
program than the real memory of computer.
RAM
PROCESSOR
PROCESSOR RAM
Memory Management Unit
MMU converts virtual address into physical address
The page table maps each VM page to either a page in main memory or a page stored on disk.
Virtual page
number is used to frame
index the page frame
table. frame
frame
2 18 = 2GB
❯ Each process has its own page table (+register), since different processes use the
same virtual addresses.
❯ The OS allocates the physical memory and updates the page tables, to avoid
collision of the virtual address spaces of different processes.
FIFO (First In First Out) : Rather than choosing the victim page at random ,the
oldest page is the first to be removed.
LRU (Least Recently Used) : Move out the page which is least rarely used .
❯ Virtual memory is implemented using,
❯ When all the pages in main memory are in use, the OS chooses a page to
replace. Replaced pages are written to swap space on the disk.
❯ Demand paging as it says ,only copies data from the disk to the RAM if the data is required
by some program, therefore meaning that the data will not be when the data is already
available on the memory.
❯ Memory is split up into equal sized sections called pages (or page frames)
❯ A single application may occupy multiple pages, which are not necessarily contiguous.
❯ Unused pages may be paged out to a swap file on disc to make room for others , Pages are
paged in when needed again
❯ When memory is low, excessive swapping can lead to disc threshing and degrade
performance
Demand Segmentation
Demand Segmentation
Demand Segmentation
Demand Segmentation
Demand Segmentation
Demand segmentation
❯ Segments are swapped between disc and main memory as needed
❯ This action will decrease the number of page faults.
❯ Data segments correspond to data structures such as stacks, queues or graphs
❯ Segments vary in size
❯ A segment in memory can be replaced by a segment of the same size or
smaller
❯ Segmentation can result in memory fragmentation; a lot of small segments
with gaps in between
❯ Segments can be "pushed together" to limit fragmentation and allow large
segments to be loaded
Usually every process has its own mapping table
Fast Address Translation: The TLB
𝟐𝒅 words
in main
memory
❑ Protection Sharing
❑ VM supports Swapping
❑ Allows more than one program to be executed at the same time.
❑ Common data or code may be shared between memory.
❑ Virtual memory increases the overall memory on a system without
adding RAM, this is advantageous as virtual memory is less
expensive.
❑ Eliminates external fragmentation.
Disadvantages
❯ If the system relies to much on virtual memory, it may cause a decrease in
performance.
❯ The more virtual memory that’s being used, the less disk space a user has
for storage.
❯ Time it takes to read from a magnetic disk is greater than the time to
access RAM, therefore swapping should be avoided wherever
performance is important.
❯ Ultimately meaning that it would take greater time to switch between
applications.