Sale notes online your Nr 1 Resource,for passing Exam at VCU
operating systems
unit 19 Operating Systems
All for this textbook (4)
Written for
Harvard University, Cambridge University
Operating System
All documents for this subject (7)
Seller
Follow
chiranjeevijami
Content preview
UNIT -III
Virtual Memory Management
Virtual Memory is a storage mechanism which offers user an illusion of having a very big
main memory. It is done by treating a part of secondary memory as the main memory. In
Virtual memory, the user can store processes with a bigger size than the available main
memory.
Why Need Virtual Memory?
Here, are reasons for using virtual memory:
Whenever your computer doesn’t have space in the physical memory it writes what it
needs to remember to the hard disk in a swap file as virtual memory.
If a computer running Windows needs more memory/RAM, then installed in the
system, it uses a small portion of the hard drive for this purpose.
Virtual Memory is a space where large programs can store themselves in
form of pages while their execution and only the required pages or
portions of processes are loaded into the main memory. This technique is
useful as a large virtual memory is provided for user programs when a
very small physical memory is there. Thus Virtual memory is a technique
that allows the execution of processes that are not in the physical
memory completely.
Virtual Memory mainly gives the illusion of more physical memory than
there really is with the help of Demand Paging.
In real scenarios, most processes never need all their pages at once, for
the following reasons :
Error handling code is not needed unless that specific error occurs,
some of which are quite rare.
Arrays are often over-sized for worst-case scenarios, and only a
small fraction of the arrays are actually used in practice.
Certain features of certain programs are rarely used.
In an Operating system, the memory is usually stored in the form of units
that are known as pages. Basically, these are atomic units used to store
large programs.
Virtual memory can be implemented with the help of:-
, 1. Demand Paging
2. Demand Segmentation
The Need for Virtual Memory
Following are the reasons due to which there is a need for Virtual
Memory:
In case, if a computer running the Windows operating system needs
more memory or RAM than the memory installed in the system then
it uses a small portion of the hard drive for this purpose.
Suppose there is a situation when your computer does not have
space in the physical memory, then it writes things that it needs to
remember into the hard disk in a swap file and that as virtual
memory.
Benefits of having Virtual Memory
1. Large programs can be written, as the virtual space available is
huge compared to physical memory.
1. /O required leads to faster and easy swapping of processes.
2. More physical memory available, as programs are stored on virtual
memory, so they occupy very little space on actual physical
memory.
3. Therefore, the Logical address space can be much larger than that
of physical address space.
4. Virtual memory allows address spaces to be shared by several
processes.
5. During the process of creation, virtual memory allows: copy-on-
write and Memory-mapped files
Execution of the Program in the Virtual memory
With the help of the Operating system few pieces of the program are
brought into the main memory:
A portion of the process that is brought in the main memory is
known as Resident Set.
, Whenever an address is needed that is not in the main memory, then it
generates an interrupt. The process is placed in the blocked state by the
Operating system. Those pieces of the process that contains the logical
address are brought into the main memory.
Demand Paging
The basic idea behind demand paging is that when a process is swapped
in, its pages are not swapped in all at once. Rather they are swapped in
only when the process needs them(On-demand). Initially, only those
pages are loaded which will be required by the process immediately.
The pages that are not moved into the memory, are marked as invalid in
the page table. For an invalid entry, the rest of the table is empty. In the
case of pages that are loaded in the memory, they are marked as valid
along with the information about where to find the swapped-out page.
Page Replacement
As studied in Demand Paging, only certain pages of a process are loaded
initially into the memory. This allows us to get more processes into
memory at the same time. but what happens when a process requests for
more pages and no free memory is available to bring them in. Following
steps can be taken to deal with this problem :
1. Put the process in the wait queue, until any other process finishes
its execution thereby freeing frames.
2. Or, remove some other process completely from the memory to free
frames.
3. Or, find some pages that are not being used right now, move them
to the disk to get free frames. This technique is called Page
replacement and is most commonly used. We have some great
algorithms to carry on page replacement efficiently.
Thrashing
A process that is spending more time paging than executing is said to be
thrashing. In other words, it means, that the process doesn't have enough
frames to hold all the pages for its execution, so it is swapping pages in
and out very frequently to keep executing. Sometimes, the pages which
will be required in the near future have to be swapped out.
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller chiranjeevijami. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $3.49. You're not tied to anything after your purchase.