The document discusses the concept of virtual memory. Virtual memory allows a program to access more memory than what is physically available in RAM by storing unused portions of the program on disk. When a program requests data that is not currently in RAM, it triggers a page fault that causes the needed page to be swapped from disk into RAM. This allows the illusion of more memory than physically available through swapping pages between RAM and disk as needed by the program during execution.
In this document
Powered by AI
Introduction of virtual memory by Maninder Kaur, highlighting its significance.
Explains virtual memory as an illusion of increased memory space, enabling programs to function beyond main memory capacity with swapping.
Defines virtual addresses and physical addresses, introducing concepts of address space and memory space.
Describes how logical addresses are mapped to physical addresses, discussing page faults and memory management.
Discusses page replacement algorithms, impacting memory allocation in case of page faults.
Details the FIFO page replacement strategy, including its operational simplicity and frequency issues with examples.
Introduces LRU page replacement, tracking usage of pages with examples to determine least recently used pages.
Discusses the optimal page replacement policy, its theoretical benefits in reducing faults, and limitations.
Final slide indicating the conclusion and end of the presentation, no additional context provided.
What is VirtualMemory?
ď‚—The term virtual memory refers to something which appears to
be present but actually it is not.
ď‚—The virtual memory technique allows users to use more
memory for a program than the real memory of a computer.
ď‚—So, virtual memory is the concept that gives the illusion to
the user that they will have main memory equal to the
capacity of secondary storage media.
2 www.eazynotes.com 24-Nov-2010
3.
Concept of VirtualMemory
ď‚— A programmer can write a program which requires more memory
space than the capacity of the main memory. Such a program is
executed by virtual memory technique.
ď‚— The program is stored in the secondary memory. The memory
management unit (MMU) transfers the currently needed part of the
program from the secondary memory to the main memory for
execution.
ď‚—
ď‚— This to and fro movement of instructions and data (parts of a
program) between the main memory and the secondary memory
is called Swapping.
3 www.eazynotes.com 24-Nov-2010
4.
Address Space AndMemory
Space
ď‚—Virtual address is the address used by the programmer and
the set of such addresses is called the address space or virtual
memory.
ď‚—An address in main memory is called a location or physical
address. The set of such locations in main memory is called
the memory space or physical memory.
4 www.eazynotes.com 24-Nov-2010
Virtual Memory (cont.)
1. CPU generated logical address consisting of a logical page number
plus the location within that page (x).
2. It must be mapped onto an actual (physical) main memory address by
the operating system using mapper.
3. If the page is present in the main memory, CPU gets the requires data
from the main memory.
4. If the mapper detects that the requested page is not present in main
memory, a page fault occurs and the page must be read from
secondary storage (4, 5) into a page frame in main memory.
6 www.eazynotes.com 24-Nov-2010
7.
Address Mapping Using
Memory Mapping Page Table
ď‚— When the requested page is not available in the main memory, we
can say that a page fault have been occurred in the main memory.
ď‚— Then the virtual address generated by the CPU is used to take out
the requested page from the secondary storage media to the main
memory to remove this page fault.
ď‚— If empty page frame is not available, then a page must be removed
from page frame in main memory.
7 www.eazynotes.com 24-Nov-2010
8.
Page Replacement Algorithms
ď‚—In a computer operating system that uses paging for virtual
memory management, page replacement algorithms decide
which memory pages to page out (swap out, write to disk)
when a page of memory needs to be allocated.
ď‚—Paging happens when a page fault occurs and a free page
cannot be used to satisfy the allocation, either because there
are none, or because the number of free pages is lower than
some threshold.
8 www.eazynotes.com 24-Nov-2010
9.
First - In- First - Out (FIFO)
ď‚— First-in-first-out is very easy to implement. The FIFO algorithm selects
the page for replacement that has been in memory the longest time.
ď‚— When a new page must be loaded, the page recently brought in is
removed. The page to be removed is easily determined because its
identification number is at the top of the FIFO stack.
ď‚— The FIFO replacement policy has the advantage of being easy to
implement.
ď‚— It has the disadvantage that under certain circumstances pages are
removed and loaded from memory too frequently.
9 www.eazynotes.com 24-Nov-2010
10.
FIFO Algorithm
ď‚— Consider a paging system having capacity of 3 pages. The execution of a
program requires references to five distinct pages P1, P2, P3, P4 and P5. The
pages are executed in the following sequence:
ď‚— P2 P3 P2 P1 P5 P2 P4 P5 P3 P2 P5 P2
10 www.eazynotes.com 24-Nov-2010
11.
Least Recently Used(LRU)
ď‚— The least recently used page (LRU) replacement algorithm keeps track
of page usage over a short period of time.
ď‚— The LRU algorithm can be implemented by associating a counter with
every page that is in main memory.
ď‚— When a page is referenced, its associated counter is set to 0. At fixed
intervals of time, the counters associated with all pages presently in
memory are incremented by 1.
ď‚— The least recently used page is the page with the highest count. The
counters are often called aging registers, as their count indicates their age,
that is, how long their associated pages have been referenced.
11 www.eazynotes.com 24-Nov-2010
12.
LRU Algorithm
ď‚— Considera paging system having capacity of 3 pages. The execution of a
program requires references to five distinct pages P1, P2, P3, P4 and P5. The
pages are executed in the following sequence:
ď‚— P2 P3 P2 P1 P5 P2 P4 P5 P3 P2 P5 P2
12 www.eazynotes.com 24-Nov-2010
13.
Optimal (OPT)
ď‚— The optimal policy selects that page for replacement for which the
time to the next reference is longest.
ď‚— This algorithm results in fewest number of page faults. But, this
algorithm is impossible to implement.
ď‚— At the time of page fault , the operating system has no way of
knowing when each of the pages will be referenced next.
However , it does serve as a standard against which to judge other
algorithms.
13 www.eazynotes.com 24-Nov-2010
14.
Optimal (OPT)
ď‚—Consider apaging system having capacity of 3 pages. The execution
of a program requires references to five distinct pages P 1, P2, P3, P4
and P5. The pages are executed in the following sequence:
ď‚—P2 P3 P2 P1 P5 P2 P4 P5 P3 P2 P5 P2
14 www.eazynotes.com 24-Nov-2010