0% found this document useful (0 votes)
3 views5 pages

Unit 4

Virtual memory is a memory management technique that allows applications to run on systems with limited physical memory by creating the illusion of a larger memory space. It includes two main types: paging and segmentation, with paging using fixed-size blocks and segmentation using variable-sized segments. Additionally, page replacement algorithms like FIFO, Optimal, and LRU help manage memory efficiently when physical memory is full, while issues like thrashing can arise from insufficient memory or high multiprogramming.

Uploaded by

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

Unit 4

Virtual memory is a memory management technique that allows applications to run on systems with limited physical memory by creating the illusion of a larger memory space. It includes two main types: paging and segmentation, with paging using fixed-size blocks and segmentation using variable-sized segments. Additionally, page replacement algorithms like FIFO, Optimal, and LRU help manage memory efficiently when physical memory is full, while issues like thrashing can arise from insufficient memory or high multiprogramming.

Uploaded by

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

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.

Types of Virtual Memory

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.

There are two main types of virtual memory:

• 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 OS maintains a page table for each process.

• 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.

Page Replacement Algorithms

Page replacement algorithms are techniques used in operating systems to manage


memory efficiently when the physical memory is full. When a new page needs to be loaded
into physical memory, and there is no free space, these algorithms determine which existing page to
replace.

Common Page Replacement Techniques

• First In First Out (FIFO)

• Optimal Page replacement

• Least Recently Used (LRU)

First In First Out (FIFO)

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.

Example: Consider the page references 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 3 with 4-page frame. Find


number of page fault using Optimal Page Replacement Algorithm.

Prepared by: Mr. Ashish Kumar Gupta, I.T.S Engineering College, Gr. Noida
Least Recently Used

In this algorithm, page will be replaced which is least recently used.

Example Consider the page reference string 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 3 with 4-page frames.


Find number of page faults using LRU Page Replacement Algorithm.

Belady's Anomaly in Page Replacement Algorithms

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.

What is a Page Fault?

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

You might also like