Memory Management:
Memory Management in Operating System (OS) is the process of managing the computer's
memory resources so that the memory for running programs can be allocated and
deallocated efficiently.
Objectives of Memory Management:
1. Efficient Use of Memory: Maximize the use of available memory.
2. Reliability: Ensure that each process runs in its own memory space, without interfering
with other processes.
3. Protection: Prevent unauthorized access to memory regions allocated to other
processes.
4. Sharing: Allow multiple processes to share common memory regions.
Memory Management Techniques:
1. Partitioning: Divide the memory into fixed-size partitions, each allocated to a process.
2. Paging: Divide the memory into fixed-size pages, each allocated to a process. Pages can
be swapped out to disk if not in use.
3. Segmentation: Divide the memory into variable-size segments, each allocated to a
process.
4. Virtual Memory: Use a combination of physical memory and disk storage to provide a
larger address space for programs.
Memory Management Units (MMU):
A Memory Management Unit (MMU) is a hardware component that translates virtual addresses
used by programs into physical addresses in memory.
Functions of MMU:
1. Address Translation: Translates virtual addresses to physical addresses.
2. Memory Protection: Prevents unauthorized access to memory regions.
3. Paging and Segmentation: Supports paging and segmentation memory management
techniques.
Types of Memory:
1. Main Memory (RAM): Volatile memory that stores data temporarily while a program is
running.
2. Secondary Memory (Disk Storage): Non-volatile memory that stores data permanently.
3. Cache Memory: Small, fast memory that stores frequently accessed data.
4. Virtual Memory: Combination of physical memory and disk storage.
Memory Allocation Algorithms:
1. First-Fit: The first block of memory large enough is allocated
2. Best-Fit: The smallest block of memory large enough is allocated.
3. Worst-Fit: The largest block of available memory is allocated
4. Next-Fit: The next block of available memory is allocated.
, Memory Deallocation:
1. Explicit De-allocation: A function for de-allocation in the program explicitly frees up
memory.
2. Implicit De-allocation: The memory will be de-allocated when a
program is terminated automatically by the operating system.
Problems with Memory Management:
1.Fragmentation: Divide memory into very small pieces, which might not give
much allocation of large pieces.
2. Paging: Pages that go to disk might cause the system to generate page
faults or reduce performance.
3. Thrashing: The process generates too many page
faults causing an increase in time spent in the swapping of pages rather than their executi
on.
Virtual Memory:
Virtual memory is a memory management capability that allows a computer to use both
physical and secondary memory (such as a hard disk drive) to provide a larger address
space for programs.
How Virtual Memory Works:
1. Program Requests Memory: A program requests memory from the operating system.
2. Operating System Allocates Virtual Memory: The operating system allocates a portion
of virtual memory to the program.
3. Virtual Memory is Mapped to Physical Memory: The virtual memory is mapped to
physical memory (RAM) or secondary memory (hard disk drive).
4. Program Accesses Virtual Memory: The program accesses the virtual memory as if it
were physical memory.
5. Operating System Manages Virtual Memory: The operating system manages the virtual
memory, swapping pages in and out of physical memory as needed.
Benefits of Virtual Memory:
1. Expanded Address Space: Virtual memory allows programs to use more memory than is
physically available by providing an expanded address space.
2. Effective Utilization of Physical Memory: Virtual memory allows the operating system
to effectively utilize physical memory, swapping pages in and out of
memory when necessary.
3. Enhanced Multitasking: Virtual memory allows for multiple programs to run
simultaneously, each with its own virtual memory space.
Types of Virtual Memory:
1. Paging: The virtual memory is divided into pages of fixed size, which get swapped in and
Memory Management in Operating System (OS) is the process of managing the computer's
memory resources so that the memory for running programs can be allocated and
deallocated efficiently.
Objectives of Memory Management:
1. Efficient Use of Memory: Maximize the use of available memory.
2. Reliability: Ensure that each process runs in its own memory space, without interfering
with other processes.
3. Protection: Prevent unauthorized access to memory regions allocated to other
processes.
4. Sharing: Allow multiple processes to share common memory regions.
Memory Management Techniques:
1. Partitioning: Divide the memory into fixed-size partitions, each allocated to a process.
2. Paging: Divide the memory into fixed-size pages, each allocated to a process. Pages can
be swapped out to disk if not in use.
3. Segmentation: Divide the memory into variable-size segments, each allocated to a
process.
4. Virtual Memory: Use a combination of physical memory and disk storage to provide a
larger address space for programs.
Memory Management Units (MMU):
A Memory Management Unit (MMU) is a hardware component that translates virtual addresses
used by programs into physical addresses in memory.
Functions of MMU:
1. Address Translation: Translates virtual addresses to physical addresses.
2. Memory Protection: Prevents unauthorized access to memory regions.
3. Paging and Segmentation: Supports paging and segmentation memory management
techniques.
Types of Memory:
1. Main Memory (RAM): Volatile memory that stores data temporarily while a program is
running.
2. Secondary Memory (Disk Storage): Non-volatile memory that stores data permanently.
3. Cache Memory: Small, fast memory that stores frequently accessed data.
4. Virtual Memory: Combination of physical memory and disk storage.
Memory Allocation Algorithms:
1. First-Fit: The first block of memory large enough is allocated
2. Best-Fit: The smallest block of memory large enough is allocated.
3. Worst-Fit: The largest block of available memory is allocated
4. Next-Fit: The next block of available memory is allocated.
, Memory Deallocation:
1. Explicit De-allocation: A function for de-allocation in the program explicitly frees up
memory.
2. Implicit De-allocation: The memory will be de-allocated when a
program is terminated automatically by the operating system.
Problems with Memory Management:
1.Fragmentation: Divide memory into very small pieces, which might not give
much allocation of large pieces.
2. Paging: Pages that go to disk might cause the system to generate page
faults or reduce performance.
3. Thrashing: The process generates too many page
faults causing an increase in time spent in the swapping of pages rather than their executi
on.
Virtual Memory:
Virtual memory is a memory management capability that allows a computer to use both
physical and secondary memory (such as a hard disk drive) to provide a larger address
space for programs.
How Virtual Memory Works:
1. Program Requests Memory: A program requests memory from the operating system.
2. Operating System Allocates Virtual Memory: The operating system allocates a portion
of virtual memory to the program.
3. Virtual Memory is Mapped to Physical Memory: The virtual memory is mapped to
physical memory (RAM) or secondary memory (hard disk drive).
4. Program Accesses Virtual Memory: The program accesses the virtual memory as if it
were physical memory.
5. Operating System Manages Virtual Memory: The operating system manages the virtual
memory, swapping pages in and out of physical memory as needed.
Benefits of Virtual Memory:
1. Expanded Address Space: Virtual memory allows programs to use more memory than is
physically available by providing an expanded address space.
2. Effective Utilization of Physical Memory: Virtual memory allows the operating system
to effectively utilize physical memory, swapping pages in and out of
memory when necessary.
3. Enhanced Multitasking: Virtual memory allows for multiple programs to run
simultaneously, each with its own virtual memory space.
Types of Virtual Memory:
1. Paging: The virtual memory is divided into pages of fixed size, which get swapped in and