Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

1. What is Virtual Memory?

Virtual memory is a technique that allows the execution of processes that are not completely in
memory. Virtual memory is a method that computers use to manage storage space to keep systems
running quickly and efficiently.

2. Demand Paging
Demand paging is a process of swapping in the Virtual Memory system. In this process, all data
is not moved from hard drive to main memory because while using this demand paging, when some
programs are getting demand then data will be transferred. The demand paging system is similar to the
paging system with swapping where processes mainly reside in the main memory (usually in the hard
disk).Demand paging is the process that solves the above problem only by swapping the pages on
Demand. This is also known as lazy swapper.(It never swaps the page into the memory unless it is
needed).Swapper that deals with the individual pages of a process are referred to as Pager. Demand
Paging is a technique in which a page is usually brought into the main memory only when it is needed or
demanded by the CPU. Initially, only those pages are loaded that are required by the process immediately.
Those pages that are never accessed are thus never loaded into the physical memory.
3. What is page fault?
Page fault is a type of error that occurs when a program tries to access a page marked invalid that
is not currently in the main memory or random access memory (RAM). When this happens, the operating
system (OS) tries to retrieve the required data from the hard disk or another storage medium, and this
process is known as a page fault. The reason for the page fault to occur : 1. Failure of OS to bring the
valid page into memory 2. Due to invalid address error.

4. Procedure for handling Page Fault


The procedure for handling this page fault is straightforward.
1. We check an internal table for this process to determine whether the reference was a valid or an
invalid memory access.
2. If the reference was invalid, we terminate the process. If the reference was valid but we have not
yet brought in that page (that mean Page Fault is occurring), it is a task of OS to check the
requested page is on the backing store. Backing store is typically a part of the hard disk that is
used for a paging system to store data that is not currently in main memory.
3. It is going to check for the required page on the disk.
4. Once it is found that the missing page is brought to the physical memory. And 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 trap. The process can now access the page as
though it had always been in memory.
5. Page Replacement
In an operating system that uses paging for memory management, a page replacement algorithm
is needed to decide which page needs to be replaced when a new page comes in. Page replacement
becomes necessary when a page fault occurs and no free page frames are in memory. Page replacement
happens when a requested page is not in memory (page fault) 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. Page Replacement simply means swapping two processes between memory and disk. Demand
Paging is a concept in which only required pages are brought into the memory.
Page replacement is basic to demand paging. It completes the separation between logical memory
and physical memory. With this mechanism, an enormous virtual memory can be provided for
programmers on a smaller physical memory. With no demand paging, user addresses are mapped into
physical addresses, and the two sets of addresses can be different. With demand paging, the size of the
logical address space is no longer constrained by physical memory. If we have a user process of twenty
pages, we can execute it in ten frames simply by using demand paging and using a replacement algorithm
to find a free frame whenever necessary.

Q1. Consider the following page reference string: 3,2,1,0,3,2,4,3,2,1,0 and the Number of page frame is 3.
Using FIFO page replacement algorithm, Find the number of Page Fault.
Q2. Consider the following page reference string: 1,7,8,3,0,2,0,3,5,4,0,6,1 and the Number of page frame
is 3. Using Optima Page Replacement algorithm, Find the number of Page Fault.
Q3. Consider the following page reference string: 0, 2, 1, 6, 4, 0, 1, 0, 3, 1, 2, 1. and the Number of page
frame is .4Using FIFO page replacement algorithm, Find the number of Page Fault.
Q4. Consider the following page reference string: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 3 and the Number of
page frame is 4. Using Optima Page Replacement algorithm, Find the number of Page Fault.

You might also like