OSY (Operating System) Project by MD ABU SHALEM ALAM "Fifth Sem Msbte Computer"
OSY (Operating System) Project by MD ABU SHALEM ALAM "Fifth Sem Msbte Computer"
PROJECT REPORT ON
“Virtual Memory”
SUBMITTED BY
Mr. MD ABU SHALEM ALAM - 2100340320
Place: - Kopargaon
Date: ----------------
1. Requirements
2. Introduction
STEPS IN HANDLING A PAGE FAULT
3. PAGE REPLACEMENT ALGORITHMS
3. Conclusion
4. References
REQUIREMENTS
❖ HARDWARE:
• Processor with minimum 258GB hard disk
• 8 GB RAM
❖ SOFTWARE:
• Windows 10
In virtual memory, the operating system divides the memory into fixed-size blocks called
pages. These pages are stored in secondary storage, such as a hard disk, when they are not
actively used. When a program needs to access a page that is not currently in physical memory,
the operating system retrieves it from secondary storage and brings it into memory.
This process is facilitated by the use of a page table, which maps the virtual addresses used by
the program to the corresponding physical addresses in memory. The page table keeps track of
which pages are currently in memory and which ones are stored in secondary storage.
Virtual memory provides several benefits. It allows for efficient memory allocation, as
programs can be allocated memory in smaller chunks rather than requiring contiguous blocks
of physical memory. It also enables memory protection, as each program's memory is isolated
from others, preventing unauthorized access.
Additionally, virtual memory enables the concept of virtual addresses, which are used by
programs, while the physical addresses are handled by the operating system. This abstraction
allows for easier program development and portability across different systems.
However, the use of virtual memory comes with some overhead. The constant swapping of
pages between physical memory and secondary storage can lead to performance degradation,
known as paging or thrashing, if not managed properly. To mitigate this, operating systems
employ various techniques like page replacement algorithms to optimize the usage of physical
memory.
In summary, virtual memory is a crucial component of modern operating systems that allows
programs to utilize more memory than physically available. It provides memory isolation,
efficient allocation, and abstraction of physical addresses, enhancing the overall performance
and usability of the system.
WHY VIRTUAL MEMORY?
• Most code/data isn't needed at any instant, or even within a finite time -
we can bring it in only as needed.
VIRTUES
• The program size isn't constrained (thus the term 'virtual memory').
Virtual memory allows very large logical address spaces.
Overlays
Laying of code data on the same logical addresses - this is the reuse of logical memory.
Useful when the program is in phases or when logical address space is small.
Dynamic loading
When a page is referenced, either as code execution or data access, and that page isn’t in
memory, then get the page from disk and re-execute the statement
Note here that the page table requires a "resident" bit showing that page is/isn't in memory.
(Book uses "valid" bit to indicate residency. An "invalid" page is that way because a legal page
isn't resident or because the address is illegal.
It makes more sense to have two bits - one indicating that the page is legal (valid) and a second
to show that the page is in memory.
STEPS IN HANDLING A PAGE FAULT
2. Check an internal table for the target process to determine if the reference was valid
(do this in hardware.)
3. If page valid, but page not resident, try to get it from secondary storage.
4. Find a free frame; a page of physical memory not currently in use. (May need to free
up a page.)
5. Schedule a disk operation to read the desired page into the newly allocated frame.
6. When memory is filled, modify the page table to show the page is now resident.
We are interested in the effective access time: a combination of "normal" and "paged" accesses.
It’s important to keep fraction of faults to a minimum. If fault ratio is "p", then
+ p * page_fault_time.
When memory is overallocated, we can either swap out some process, or overwrite some
pages. Which pages should we replace?? <--- here the goal is to minimize the number of
faults.
Here is an example reference string we will use to evaluate fault mechanisms:
Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
FIFO
• This is the replacement policy that results in the lowest page fault rate.
• Algorithm: Replace that page which will not be next used
for the longest period of time.
• Impossible to achieve in practice; requires crystal ball.
Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
4 1
6 page faults 2
5 4
Conclusion
virtual memory is a crucial aspect of operating systems that allows programs to utilize more
memory than physically available. It provides benefits such as efficient memory allocation,
memory protection, and abstraction of physical addresses. However, it also introduces
overhead and the potential for performance degradation if not managed properly. Overall,
virtual memory plays a vital role in enhancing the performance and usability of operating
systems.
virtual memory is like a superpower for operating systems! It allows programs to use more
memory than what's physically available. This helps with efficient memory management,
protection, and makes things easier for developers. However, it can slow things down if not
managed properly. Overall, virtual memory is a game-changer for operating systems!
To wrap it up, virtual memory is a crucial feature in operating systems that allows programs
to utilize more memory than what's physically available. It offers benefits like efficient
memory allocation, protection, and portability. However, it can introduce performance
overhead if not managed effectively. Overall, virtual memory is a game-changer that enhances
the functionality and performance of operating systems.
References