UNIT IV
MEMORY MANAGEMENT
Page frame management
• The Page Fault exceptions issued by the paging circuitry are easily
interpreted. Either the page requested exists but the process is not
allowed to address it, or the page does not exist. In the second case,
the memory allocator must find a free 4 KB page frame and assign it
to the process.
• The 4 KB size is a multiple of most disk block sizes, so transfers of
data between main memory and disks are more efficient. Yet this
smaller size is much more manageable than the 4 MB size.
Page descriptors
• The kernel must keep track of the current status of each page frame. For
instance, it must be able to distinguish the page frames that are used to
contain pages that belong to processes from those that contain kernel code
or kernel data structures.
• Similarly, it must be able to determine whether a page frame in dynamic
memory is free. A page frame in dynamic memory is free if it does not
contain any useful data.
• It is not free when the page frame contains data of a User Mode process,
data of a software cache, dynamically allocated kernel data structures,
buffered data of a device driver, code of a kernel module, and so on
Non-uniform memory access
• We are used to thinking of the computer’s memory as an homogeneous,
shared resource.
• Disregarding the role of the hardware caches, we expect the time required
for a CPU to access a memory location is essentially the same, regardless of
the location’s physical address and the CPU.
• Unfortunately, this assumption is not true in some architectures. For
instance, it is not true for some multiprocessor Alpha or MIPS computers
Memory zones
• In the context of the OSI (Open Systems Interconnection) model, "memory
zones" do not have a standard or widely recognized meaning.
• The OSI model is a conceptual framework used to understand and
standardize how different networking protocols and technologies interact in
a networked environment.
• It consists of seven layers, each responsible for specific functions related to
network communication.
Reserved page frames
• Page frames" typically refer to a concept in computer memory management,
particularly in the context of virtual memory and operating systems.
• In this context, a page frame is a fixed-size block of physical memory used
to store pages of data that have been swapped in and out of main memory.
• The kernel's code and data structures are stored in a group of reserved page
frames.
• A page contained in one of these page frames can never be dynamically
assigned or swapped to disk.
Zoned page frame allocator
• Zoned page frame allocators are particularly useful in systems where
memory requirements are diverse and distinct.
• They help optimize memory usage and maintain performance by
minimizing fragmentation and efficiently allocating memory based on the
specific needs of different parts of the system.
• This can be crucial in resource-constrained environments where memory
efficiency is paramount.
kernel mappings
• Especially operating systems, kernel mappings refer to the mechanisms and
techniques used to provide access to the kernel's code and data from user
processes while maintaining the separation between user-mode and kernel-
mode operations.
• Kernel mappings allow user processes to interact with the kernel's
functionality without directly accessing its memory space, ensuring security,
stability, and isolation.
• Virtual Memory
• Kernel Space and User Space
• Kernel Mapping
• System Calls
• Context Switching
• Page Tables
Buddy system algorithm
• The buddy system algorithm is a memory allocation and management
technique used in operating systems to efficiently manage memory blocks
of varying sizes.
• It helps address issues related to memory fragmentation and enhances
memory utilization by allocating memory in powers of two sizes.
• This algorithm is often used in kernel-level memory management and is
particularly effective for managing memory in systems with dynamic
memory allocation needs.
• Assume the size of memory is 2m and the size of the process is P.
• If 2m-1 < P <= 2m, we will allocate the memory to the process. Otherwise,
we will divide the memory blocks into equal halves and check for the
condition as mentioned earlier. If it does not satisfy the requirement, we will
recursively repeat this step until it fulfills the condition
Page frame cache
• It seems like you might be referring to a "page frame cache" in the context
of memory management or operating systems.
• However, the term "page frame cache" isn't a commonly used term, and it
could be a combination of concepts. Let's break down the potential
components:
1. Page Frame
2. Cache
• Page Frame: A page frame is a fixed-size block of physical
memory used in virtual memory systems. It corresponds to the
basic unit of data transfer between main memory and storage
devices. Pages are typically 4 KB in size on x86 systems, but
this size can vary depending on the architecture.
• Cache: A cache is a small, high-speed memory that stores
frequently accessed data for quicker retrieval. In the context of
memory management, caches are often used to store copies of
data from main memory to reduce the latency of accessing that
data.
• Given these components, a "page frame cache" could potentially refer to a
cache that stores frequently used or recently accessed page frames. This
kind of caching might be employed to optimize memory access times,
especially in scenarios where memory pages are being moved between main
memory and secondary storage (e.g., disk). This could help reduce the
impact of slower storage access times on the system's overall performance.
• In an operating system, the concept of a page frame cache might involve
managing which page frames are cached in memory to improve efficiency.
Pages that are accessed frequently or are likely to be accessed soon could be
kept in memory, while less frequently used pages could be evicted from the
cache to make room for new pages.
Zone allocator
• A zone allocator is a type of memory allocation mechanism used in
operating systems and memory management systems.
• It involves dividing the available memory into distinct zones, with each
zone dedicated to a specific type of memory allocation.
• This approach is often used to improve memory management efficiency by
reducing fragmentation and optimizing memory allocation patterns for
different use cases.
zone allocator typically works:
• Memory Division
• Zone Management
• Allocation
• Deallocation
• Fragmentation Mitigation
• Zone-Specific Policies
Example:
typedef struct _vm_zone_t {
struct _vm_zone_t *next;
struct _vm_zone_t *prev;
rbnode_t linkage;
size_t blocksz;
volatile unsigned int blocks;
volatile unsigned int used;
void *vaddr;
void *first;
page_t *pages;
} vm_zone_t;

UNIT IV.pptx

  • 1.
  • 2.
    Page frame management •The Page Fault exceptions issued by the paging circuitry are easily interpreted. Either the page requested exists but the process is not allowed to address it, or the page does not exist. In the second case, the memory allocator must find a free 4 KB page frame and assign it to the process. • The 4 KB size is a multiple of most disk block sizes, so transfers of data between main memory and disks are more efficient. Yet this smaller size is much more manageable than the 4 MB size.
  • 3.
    Page descriptors • Thekernel must keep track of the current status of each page frame. For instance, it must be able to distinguish the page frames that are used to contain pages that belong to processes from those that contain kernel code or kernel data structures. • Similarly, it must be able to determine whether a page frame in dynamic memory is free. A page frame in dynamic memory is free if it does not contain any useful data. • It is not free when the page frame contains data of a User Mode process, data of a software cache, dynamically allocated kernel data structures, buffered data of a device driver, code of a kernel module, and so on
  • 4.
    Non-uniform memory access •We are used to thinking of the computer’s memory as an homogeneous, shared resource. • Disregarding the role of the hardware caches, we expect the time required for a CPU to access a memory location is essentially the same, regardless of the location’s physical address and the CPU. • Unfortunately, this assumption is not true in some architectures. For instance, it is not true for some multiprocessor Alpha or MIPS computers
  • 5.
    Memory zones • Inthe context of the OSI (Open Systems Interconnection) model, "memory zones" do not have a standard or widely recognized meaning. • The OSI model is a conceptual framework used to understand and standardize how different networking protocols and technologies interact in a networked environment. • It consists of seven layers, each responsible for specific functions related to network communication.
  • 6.
    Reserved page frames •Page frames" typically refer to a concept in computer memory management, particularly in the context of virtual memory and operating systems. • In this context, a page frame is a fixed-size block of physical memory used to store pages of data that have been swapped in and out of main memory. • The kernel's code and data structures are stored in a group of reserved page frames. • A page contained in one of these page frames can never be dynamically assigned or swapped to disk.
  • 7.
    Zoned page frameallocator • Zoned page frame allocators are particularly useful in systems where memory requirements are diverse and distinct. • They help optimize memory usage and maintain performance by minimizing fragmentation and efficiently allocating memory based on the specific needs of different parts of the system. • This can be crucial in resource-constrained environments where memory efficiency is paramount.
  • 9.
    kernel mappings • Especiallyoperating systems, kernel mappings refer to the mechanisms and techniques used to provide access to the kernel's code and data from user processes while maintaining the separation between user-mode and kernel- mode operations. • Kernel mappings allow user processes to interact with the kernel's functionality without directly accessing its memory space, ensuring security, stability, and isolation.
  • 10.
    • Virtual Memory •Kernel Space and User Space • Kernel Mapping • System Calls • Context Switching • Page Tables
  • 11.
    Buddy system algorithm •The buddy system algorithm is a memory allocation and management technique used in operating systems to efficiently manage memory blocks of varying sizes. • It helps address issues related to memory fragmentation and enhances memory utilization by allocating memory in powers of two sizes. • This algorithm is often used in kernel-level memory management and is particularly effective for managing memory in systems with dynamic memory allocation needs.
  • 12.
    • Assume thesize of memory is 2m and the size of the process is P. • If 2m-1 < P <= 2m, we will allocate the memory to the process. Otherwise, we will divide the memory blocks into equal halves and check for the condition as mentioned earlier. If it does not satisfy the requirement, we will recursively repeat this step until it fulfills the condition
  • 13.
    Page frame cache •It seems like you might be referring to a "page frame cache" in the context of memory management or operating systems. • However, the term "page frame cache" isn't a commonly used term, and it could be a combination of concepts. Let's break down the potential components: 1. Page Frame 2. Cache
  • 14.
    • Page Frame:A page frame is a fixed-size block of physical memory used in virtual memory systems. It corresponds to the basic unit of data transfer between main memory and storage devices. Pages are typically 4 KB in size on x86 systems, but this size can vary depending on the architecture. • Cache: A cache is a small, high-speed memory that stores frequently accessed data for quicker retrieval. In the context of memory management, caches are often used to store copies of data from main memory to reduce the latency of accessing that data.
  • 15.
    • Given thesecomponents, a "page frame cache" could potentially refer to a cache that stores frequently used or recently accessed page frames. This kind of caching might be employed to optimize memory access times, especially in scenarios where memory pages are being moved between main memory and secondary storage (e.g., disk). This could help reduce the impact of slower storage access times on the system's overall performance. • In an operating system, the concept of a page frame cache might involve managing which page frames are cached in memory to improve efficiency. Pages that are accessed frequently or are likely to be accessed soon could be kept in memory, while less frequently used pages could be evicted from the cache to make room for new pages.
  • 16.
    Zone allocator • Azone allocator is a type of memory allocation mechanism used in operating systems and memory management systems. • It involves dividing the available memory into distinct zones, with each zone dedicated to a specific type of memory allocation. • This approach is often used to improve memory management efficiency by reducing fragmentation and optimizing memory allocation patterns for different use cases.
  • 17.
    zone allocator typicallyworks: • Memory Division • Zone Management • Allocation • Deallocation • Fragmentation Mitigation • Zone-Specific Policies
  • 18.
    Example: typedef struct _vm_zone_t{ struct _vm_zone_t *next; struct _vm_zone_t *prev; rbnode_t linkage; size_t blocksz; volatile unsigned int blocks; volatile unsigned int used; void *vaddr; void *first; page_t *pages; } vm_zone_t;