0% found this document useful (0 votes)
12 views7 pages

Virtual Memory

Uploaded by

jaiswaljijaji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views7 pages

Virtual Memory

Uploaded by

jaiswaljijaji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Understanding Virtual

Memory
Sumit Jaiswal
Introduction
• One of the most important aspects of an operating system is the Virtual Memory Management
system.
• Virtual Memory (VM) allows an operating system to perform many of its advanced functions,
such as process isolation, file caching, and swapping.
• To properly understand how a Virtual Memory Manager does its job, it helps to understand what
components comprise a VM. While the low level view of a VM are overwhelming for most, a
high level view is necessary to understand how a VM works and how it can be optimized for
workloads.
MMU

• The Memory Management Unit (MMU)


is the hardware base that makes a VM
system possible. The MMU allows MMU

software to reference physical memory


by aliased addresses, quite often more
than one. It accomplishes this through
the use of pages and page tables. The
MMU uses a section of memory to
translate virtual addresses into physical
addresses via a series of table lookups.
Zoned Buddy Allocator

• The Zoned Buddy Allocator is responsible for the management


of page allocations to the entire system. This code manages
lists of physically contiguous pages and maps them into the
MMU page tables, so as to provide other kernel subsystems
with valid physical address ranges when the kernel requests
them (Physical to Virtual Address mapping is handled by a
higher layer of the VM). The name Buddy Allocator is derived Zoned

from the algorithm this subsystem uses to maintain it free page Buddy
Allocat
-or

lists. All physical pages in RAM are cataloged by the Buddy


Allocator and grouped into lists. Each list represents clusters of
2n pages, where n is incremented in each list. If no entries exist
on the requested list, an entry from the next list up is broken
into two separate clusters and is returned to the caller while
the other is added to the next list down. When an allocation is
returned to the buddy allocator, the reverse process happens.
Note that the Buddy Allocator also manages memory zones,
which define pools of memory which have different purposes.
Currently there are three memory pools which the Buddy
Allocator manages accesses for:
DMA, NORMAL and HIGHMEM
• DMA — This zone consists of the first 16 MB of RAM, from which
legacy devices allocate to perform direct memory operations.

• NORMAL — This zone encompasses memory addresses from 16 MB


to 1 GB and is used by the kernel for internal data structures as well
as other system and user space allocations.

• HIGHMEM — This zone includes all memory above 1 GB and is used


exclusively for system allocations (file system buffers, user space
allocations, etc).
Slab Allocator

• The Slab Allocator provides a more usable front end to the Buddy Allocator for
those sections of the kernel which require memory in sizes that are more
flexible than the standard 4 KB page. The Slab Allocator allows other kernel
components to create caches of memory objects of a given size. The Slab
Allocator is responsible for placing as many of the cache's objects on a page as
possible and monitoring which objects are free and which are allocated. When
allocations are requested and no more are available, the Slab Allocator requests
more pages from the Buddy Allocator to satisfy the request. This allows kernel
components to use memory in a much simpler way. This way components
which make use of many small portions of memory are not required to
individually implement memory management code so that too many pages are
not wasted. The Slab Allocator may only allocate from the DMA and NORMAL
zones.

You might also like