0% found this document useful (0 votes)
5 views19 pages

OSYReport

The document is a micro project report on 'Virtual Memory' submitted by three students from Shree Mouni Vidhyapeeth’s Institute of Civil and Rural Engineering for their Diploma in Computer Engineering. It covers the rationale, aims, methodology, and literature review related to virtual memory, including concepts like paging, fragmentation, and segmentation. The project is guided by Mr. M. A. Pilankar and fulfills academic requirements for the Operating System course.

Uploaded by

sarvjitp21
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)
5 views19 pages

OSYReport

The document is a micro project report on 'Virtual Memory' submitted by three students from Shree Mouni Vidhyapeeth’s Institute of Civil and Rural Engineering for their Diploma in Computer Engineering. It covers the rationale, aims, methodology, and literature review related to virtual memory, including concepts like paging, fragmentation, and segmentation. The project is guided by Mr. M. A. Pilankar and fulfills academic requirements for the Operating System course.

Uploaded by

sarvjitp21
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

Shree Mouni Vidhyapeeth’s

Institute of Civil and Rural Engineering, Gargoti

A
Micro Project Report

Under The Course

Operating System (22516)

With Title

Virtual Memory
Submitted by

Roll. No. Names of Students

37. Patil Pranali Baccharam


38. Chougale Shruti Sarjerao
39. Patil Sarvajit Vasant

Under the Guidance of


Mr. M. A. Pilankar

In Partial Fulfilment of

Diploma in Computer Engineering

Academic Year : 2023-24


CERTIFICATE

This is to certify that the Micro project entitled “Virtual Memory” under the course of “Operating
System (22516)” submitted to the Institute of Civil and Rural Engineering, Gargoti in partial fulfilment
of Diploma in Computer Engineering is a record of original work done by Pranali, Shruti and Sarvajit
during the period from 2023 to 2024 under the supervision and guidance of Mr. M. A. Pilankar and it
has not copied or submitted with other similar title by any candidates in this Diploma College.

Signature Signature Signature


Project Guide Head of the Department Principal
DECLARATION

We all hereby, Pranali, Shruti and Sarvajit declares that the Micro Project submitted to the Institute of
Civil and Rural Engineering, Gargoti in partial fulfilment of Diploma in Computer Engineering done in
the period of 2023 to 2024 under the supervision and guidance of Mr. M. A. Pilankar, Senior Lecturer
in Department of Computer Engineering. The project has not copied or submitted with other similar
title by an any candidate in this diploma college.

Date:

Place: Gargoti Signature of Candidate Sign

37. Patil Pranali Baccharam


38. Chougale Shruti Sarjerao
39. Patil Sarvajit Vasant
Maharashtra State Board of Technical Education

Certificate

This is to certify that. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Roll No . . . . . . of


fifth semester of Diploma in Computer Engineering Form Institute Civil & Rural Engineering
(code : 0012) has completed the micro project work satisfactorily in course Operating System
(22516) For the academic year 2023-2024 as prescribed in the curriculum.

Title : Virtual Memory

Date: Enrollment No.:

Place: Exam Seat No:

Signature Signature Signature


Project Guide Head of the Department Principal
Table of Contents

1 Rationale 1

2 Aims and Benefits of Micro Project 1

3 Course Outcomes Addressed 2

4 Literature Review 2

5 Actual Methodology Followed 3


5.1 Virtual Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
5.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
5.1.2 What is Virtual Memory ? . . . . . . . . . . . . . . . . . . . . . . . . 4
5.1.3 Diagram showing in virtual memory that is larger than physical memory 4
5.2 Introduction to paging:- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
5.2.1 Paging Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
5.2.2 Page table when some pages are not in main memory. . . . . . . . . . . 6
5.2.3 Paging example for 32 K memory with 4 K memory. . . . . . . . . . . 7
5.3 Fragmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5.3.1 Internal Fragmentation . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5.3.2 External Fragmentation . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5.4 Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.4.1 Virtual Memory Segmentation: . . . . . . . . . . . . . . . . . . . . . 10
5.4.2 Simple Segmentation: . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.5 Page Fault . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.5.1 Page Fault Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.5.2 Steps in handling a page fault. . . . . . . . . . . . . . . . . . . . . . . 13

6 Actual Resources Used 14

7 Skill Developed/ Learning Outcomes of This Micro-Project 14

1
Chapter 1
Rationale

Virtual memory is a fundamental concept in computer science and operating systems. It pro-
vides a logical extension of a computer’s physical memory by using a combination of RAM
(Random Access Memory) and secondary storage, such as a hard drive. The rationale for vir-
tual memory is to optimize the utilization of available physical memory and enable efficient
multitasking.
By employing virtual memory, a computer can run multiple processes concurrently, even if
their combined memory requirements exceed the physical RAM capacity. It achieves this by
swapping data between RAM and secondary storage as needed, creating an illusion of large
memory space for each process.
It also simplifies memory management and enhances the overall user experience by allow-
ing for smoother and more efficient task execution. In essence, virtual memory is a crucial
component of modern computing systems, enabling them to handle complex tasks and run
multiple applications seamlessly.

Chapter 2
Aims and Benefits of Micro Project

• Understanding Virtual Memory: deep understanding of virtual memory concepts and its
significance in modern operating systems.

• Opportunities for enhancements and optimizations to enhance system efficiency and


resource management.

1
Chapter 3
Course Outcomes Addressed

a) Calculate efficiency of different memory management techniques.

b)

c)

d)

Chapter 4
Literature Review

There are provides a foundational understanding of virtual memory concepts and their
relevance in modern computer systems and operating systems:

• Page Tables are crucial data structures that map virtual addresses to physical addresses,
facilitating address translation for efficient memory access

• Page Replacement Algorithms like FIFO, LRU, and Optimal are vital for minimizing
page faults and optimizing memory usage by determining which pages to keep in physical
memory.

• Demand Paging optimizes memory management by loading pages into memory only
when needed, reducing initial memory consumption and enhancing system efficiency.

• Virtual memory is a fundamental component in modern operating systems, enabling mul-


titasking and efficient memory allocation, essential for running multiple programs simul-
taneously.

2
Chapter 5
Actual Methodology Followed

5.1 Virtual Memory

5.1.1 Introduction

Virtual memory is a foundational concept in computer science and operating systems that plays
a critical role in the efficient management of memory resources. This technology addresses the
inherent limitations of physical RAM by providing an abstract layer that extends the available
memory space. At its core, virtual memory allows a computer to run multiple programs simul-
taneously, even if their combined memory requirements exceed the physical RAM capacity.
The key idea behind virtual memory is to create an illusion of ample memory space for each
process. It does this by temporarily transferring data between RAM (Random Access Memory)
and secondary storage, such as a hard drive, as needed. When a program needs data that is not
currently in physical memory, the system orchestrates the retrieval of the required data from
secondary storage, replacing less relevant data to make room for it.
Virtual memory is a fundamental component of modern operating systems, providing stability,
memory isolation, and the ability to run complex software applications. It allows for seamless
multitasking, as each process believes it has access to a dedicated portion of memory. The
technology optimizes memory usage, reducing the likelihood of memory-related errors and
ensuring a smooth and efficient user experience.

3
5.1.2 What is Virtual Memory ?

Virtual memory is a technique that allows the execution of processes that may not be completely
in memory. One major advantage of this scheme is that programs can be larger than physical
memory. Further, virtual memory abstracts main memory into an extremely large, uniform ar-
ray of storage, separating logical memory as viewed by the user from physical memory. This
technique frees programmers from the concerns of memory-storage [Link] mem-
ory is a storage allocation scheme in which secondary memory can be addressed as though it
were part of main [Link] memory is implemented using :- Demand Paging or Demand
Segmentation

5.1.3 Diagram showing in virtual memory that is larger than physical memory

Virtual memory is the separation of user logical memory from physical memory. This
separation allows an extremely large virtual memory to be provided for programmers when
only a smaller physical memory is available . Virtual memory makes the task of programming
much easier, because the programmer no longer needs to worry about the amount of physical
memory available, or about what code can be placed in overlays.

4
5.2 Introduction to paging:-

Paging is a memory management scheme that eliminates the need for contiguous allocation of
physical memory. This scheme permits the physical address space of a process to be non –
contiguous. Traditionally, support for paging has been handled by hardware. Recent designs
have implemented paging by closely integrating the hardware and operating system

5.2.1 Paging Hardware

Physical memory is broken into fixed-sized blocks called frames. Logical memory is also bro-
ken into blocks of the same size called pages. When a process is to be executed, its pages are
loaded into any available memory frames from the backing store. The backing store is divided
into fixed-sized blocks that are of the same size as the memory frames.
Physical memory is broken into fixed-sized blocks called frames. Logical memory is also bro-
ken into blocks of the same size called pages. When a process is to be executed, its pages are
loaded into any available memory frames from the backing store. The backing store is divided
into fixed-sized blocks that are of the same size as the memory frames.

5
Every address generated by the CPU is divided into two parts: –
A page number (p) The page number is used as an index into a page table The page table con-
tains the base address of each page in physical memory.
A page offset (d). Base address is combined with the page offset to define the physical memory
address that is sent to the memory unit.

5.2.2 Page table when some pages are not in main memory.

The basic idea behind paging is that when a process is swapped in, the pager only loads into
memory those pages that it expects the process to need (right away.) Pages that are not loaded
into memory are marked as invalid in the page table, using the invalid bit. (The rest of the page
table entry may either be blank or contain information about where to find the swapped-out
page on the hard drive.) If the process only ever accesses pages that are loaded in memory
(memory resident pages), then the process runs exactly as if all the pages were loaded in to
memory. The basic idea behind paging is that when a process is swapped in, the pager only
loads into memory those pages that it expects the process to need (right away.) Pages that are
not loaded into memory are marked as invalid in the page table, using the invalid bit. (The
rest of the page table entry may either be blank or contain information about where to find the
swapped-out page on the hard drive.) If the process only ever accesses pages that are loaded in
memory (memory resident pages), then the process runs exactly as if all the pages were loaded
in to memory.

6
5.2.3 Paging example for 32 K memory with 4 K memory.

1. We have 4 pages and each page is 4 bytes.

2. Logical address 0 is page 0 and offset 0.

3. Page 0 is in frame 5.

4. Logical address maps to physical address (5x4)+0=20

5. Logical address 3 (page 0, offset 3) maps to physical address (5x4)+3=23.

6. Logical address 4 (page 1, offset 0) maps to physical address (6x4)+0=24.

7. Logical address 13 maps to physical address (2x4)+1=9.

7
5.3 Fragmentation

Fragmentation is an unwanted problem in the operating system in which the processes are
loaded and unloaded from memory, and free memory space is fragmented. Processes can’t be
assigned to memory blocks due to their small size, and the memory blocks stay unused. It
is also necessary to understand that as programs are loaded and deleted from memory, they
generate free space or a hole in the memory. These small blocks cannot be allotted to new
arriving processes, resulting in inefficient memory use.
There are mainly two types of fragmentation in the operating system. These are as follows:
1. Internal Fragmentation
2. External Fragmentation

5.3.1 Internal Fragmentation

Internal Fragmentation

When a process is allocated to a memory block, and if the process is smaller than the amount
of memory requested, a free space is created in the given memory block. Due to this, the free
space of the memory block is unused, which causes internal fragmentation.
For Example: Assume that memory allocation in RAM is done using fixed partitioning (i.e.,
memory blocks of fixed sizes).2MB, 4MB, 4MB, and 8MB are the available sizes. The Oper-
ating System uses a part of this RAM.
Let’s suppose a process P1 with a size of 3MB arrives and is given a memory block of 4MB. As
a result, the 1MB of free space in this block is unused and cannot be used to allocate memory
to another process. It is known as internal fragmentation.

8
5.3.2 External Fragmentation

External Fragmentation

External fragmentation happens when a dynamic memory allocation method allocates some
memory but leaves a small amount of memory unusable. The quantity of available memory
is substantially reduced if there is too much external fragmentation. There is enough memory
space to complete a request, but it is not contiguous. It’s known as external fragmentation.
For Example:
Let’s take the example of external fragmentation. In the above diagram, you can see that there is
sufficient space (50 KB) to run a process (05) (need 45KB), but the memory is not contiguous.
You can use compaction, paging, and segmentation to use the free space to execute a process.

9
5.4 Segmentation

Segmentation is a memory management technique in which the memory is divided into the
variable size parts. Each part is known as a segment which can be allocated to a process.
Types of Segmentation in Operating System

5.4.1 Virtual Memory Segmentation:

Each process is divided into a number of segments, but the segmentation is not done all at once.
This segmentation may or may not take place at the run time of the program.

5.4.2 Simple Segmentation:

Each process is divided into a number of segments, all of which are loaded into memory at
run time, though not necessarily contiguously. There is no simple relationship between logical
addresses and physical addresses in segmentation. A table stores the information about all such
segments and is called Segment Table.

10
• Segment Table

The details about each segment are stored in a table called a segment table. Segment table is
stored in one (or many) of the segments.

• Segment table contains mainly two information about segment:


1. Base: It is the base address of the segment
2. Limit: It is the length of the segment

• The address generated by the CPU is divided into:

1. Segment number (s): Number of bits required to represent the segment.


2. Segment offset (d): Number of bits required to represent the size of the segment.

11
5.5 Page Fault

Page faults dominate more like an error. A page fault will happen if a program tries to access a
piece of memory that does not exist in physical memory (main memory). The fault specifies the
operating system to trace all data into virtual memory management and then relocate it from
secondary memory to its primary memory, such as a hard disk.
A page fault trap occurs if the requested page is not loaded into memory. The page fault pri-
marily causes an exception, which is used to notify the operating system to retrieve the ”pages”
from virtual memory to continue operation. Once all of the data has been placed into physical
memory, the program resumes normal operation. The Page fault process occurs in the back-
ground, and thus the user is unaware of it.
1) The computer’s hardware track to the kernel and the program counter is often saved on the
stack. The CPU registers hold information about the current state of instruction.
2) An assembly program is started, which saves the general registers and other volatile data to
prevent the Operating system from destroying it.

5.5.1 Page Fault Handling

A Page Fault happens when you access a page that has been marked as invalid. The paging
hardware would notice that the invalid bit is set while translating the address across the page
table, which will cause an operating system trap. The trap is caused primarily by the OS’s
failure to load the needed page into memory.
Now, let’s understand the procedure of page fault handling in the OS:
1) Firstly, an internal table for this process to assess whether the reference was valid or invalid
memory access.
2) If the reference becomes invalid, the system process would be terminated. Otherwise, the
page will be paged in.
3) After that, the free-frame list finds the free frame in the system.
4) Now, the disk operation would be scheduled to get the required page from the disk.
5) When the I/O operation is completed, the process’s page table will be updated with a new
frame number, and the invalid bit will be changed. Now, it is a valid page reference.
6) If any page fault is found, restart these steps from starting.

12
5.5.2 Steps in handling a page fault.

1) We check an internal table (usually kept with the process control block) for this process, to
determine whether the reference was a valid or invalid memory access.

2) If the reference was invalid, we terminate the process. If it was valid, but we have not
yet brought in that page, we now page it in.

3) We find a free frame (by taking one from the free-frame list, for example).

4) We schedule a disk operation to read the desired page into the newly allocated frame.

5) When the disk read is complete, we modify the internal table kept with the process and
the page table to indicate that the page is now in memory.

6) We restart the instruction that was interrupted by the illegal address trap. The process can
now access the page as though it had always been in memory.

13
Chapter 6
Actual Resources Used

[Link]. Name of Used Resources Specification Quantity


l Laptop i5 RAM 8 GB 1 Each
2 Software TexMaker 1 Each
3 Reference Book Operating System Concepts Abraham Silber- 1 Each
schatz (9th,2012)
4 Laboratory Manual Programming with Python 1 Each

Chapter 7
Skill Developed/ Learning Outcomes of This Micro-Project

1. Deep understanding of virtual memory principles, mechanisms in modern computing


systems.

2. Critical thinking and decision-making skills for choosing the right interface for different
tasks.

3. Improved research and analytical skills.

4. Effective communication through the creation of a comprehensive report and presenta-


tion.

14

You might also like