Unit 4
Unit 4
Virtual Memory
Virtual memory is a memory management technique used by operating systems to give the
appearance of a large, continuous block of memory to applications, even if the physical memory
(RAM) is limited. It allows larger applications to run on systems with less RAM.
In a computer, virtual memory is managed by the Memory Management Unit (MMU), which is often
built into the CPU. The CPU generates virtual addresses that the MMU translates into physical
addresses.
• Paging
• Segmentation
Paging: Paging in an operating system is a memory management technique that allows processes to
use more memory than is physically available by dividing both the processes and the physical
memory into fixed-size blocks called pages and frames, respectively. This enables non-contiguous
memory allocation and helps manage memory more efficiently.
Page Tables:
• The page table maps virtual addresses (used by the process) to physical addresses (actual
locations in RAM).
• Each entry in the page table corresponds to a page and indicates which frame (if any) the
page is currently loaded into.
Demand paging: Demand paging is a memory management technique where a program's pages are
loaded into physical memory (RAM) only when they are needed during execution
Prepared by: Mr. Ashish Kumar Gupta, I.T.S Engineering College, Gr. Noida
Segmentation: In an operating system, segmentation is a memory management technique where a
process is divided into logical, variable-sized segments, such as code, data, or stack. These segments
are then allocated to memory, and the operating system uses a segment table to manage them,
mapping logical addresses to physical memory locations.
This is the simplest page replacement algorithm. In this algorithm, the operating system keeps track
of all pages in the memory in a queue, the oldest page is in the front of the queue. When a page
needs to be replaced page in the front of the queue is selected for removal.
Example: Consider page reference string 1, 3, 0, 3, 5, 6, 3 with 3-page frames. Find the number of
page faults using FIFO Page Replacement Algorithm.
Prepared by: Mr. Ashish Kumar Gupta, I.T.S Engineering College, Gr. Noida
Optimal Page Replacement
In this algorithm, pages are replaced which would not be used for the longest duration of time in the
future.
Prepared by: Mr. Ashish Kumar Gupta, I.T.S Engineering College, Gr. Noida
Least Recently Used
Belady's Anomaly is a phenomenon in operating systems where increasing the number of page
frames in memory leads to an increase in the number of page faults for certain page replacement
algorithms.
A page fault is a type of interrupt or exception that occurs in a computer's operating system when a
program attempts to access a page of memory that is not currently loaded into physical RAM
(Random Access Memory).
Thrashing: Thrashing in an operating system (OS) is a performance issue where the system spends
most of its time swapping pages between main memory and secondary storage (like a hard drive),
rather than executing processes. This excessive swapping leads to very slow system performance, or
even a standstill.
Prepared by: Mr. Ashish Kumar Gupta, I.T.S Engineering College, Gr. Noida
Causes of Thrashing:
1. Insufficient Memory
2. High Degree of Multiprogramming
3. Inefficient Memory Allocation
4. Page Faults
Working set window Model: In the context of operating systems, a working set window refers to a
fixed-size window of recent page references used to determine the working set of a process. The
working set represents the set of pages a process is actively using at a given time. By tracking page
references within this window, the operating system can estimate which pages are likely to be
needed in the near future and manage memory accordingly.
Prepared by: Mr. Ashish Kumar Gupta, I.T.S Engineering College, Gr. Noida