Home | | Operating Systems | Virtual Memory

Chapter: Operating Systems : Storage Management

Virtual Memory

It is a technique that allows the execution of processes that may not be completely in main memory.

VIRTUAL MEMORY

 

ü It is a technique that allows the execution of processes that may not be completely in main memory.

 

ü Advantages:

 

o Allows the program that can be larger than the physical memory. o Separation of user logical memory from physical memory

 

Allows processes to easily share files & address space.

 

o   Allows for more efficient process creation.

 

ü Virtual memory can be implemented using

 

o   Demand paging

 

Demand segmentation

 

Fig 3.5 Virtual Memory That is Larger than Physical Memory

 

Demand Paging


 

ü It is similar to a paging system with swapping.

 

ü Demand Paging - Bring a page into memory only when it is needed

 

ü To execute  a  process,  swap  that  entire  process  into  memory.  Rather  than swapping

the entire process into memory however, we use  Lazy Swapper

 

2.3.1.    Lazy Swapper - Never swaps a page into memory unless that page will be needed.

 

2.3.2.      Advantages

 

Less I/O needed

 

Less memory needed

 

Faster response

 

More users

 

Basic Concepts:

 

v Instead of swapping in the whole processes, the pager brings only those necessary pages into memory. Thus,

 

It avoids reading into memory pages that will not be used anyway.

 

Reduce the swap time.

 

o   Reduce the amount of physical memory needed.

 

v To differentiate between those pages that are in memory & those that are on the disk we use the Valid-Invalid bit

 

Valid-Invalid bit

 

v A valid invalid bit is associated with each page table entry.

 

v Valid associated page is in memory.

 

v In-Valid

 

invalid page

 

valid page but is currently on the disk.

 

Page Fault

 

v Access to a page marked invalid causes a page fault trap.

 

1.   Determine whether the reference is a valid or invalid memory access

 

2.   a) If the reference is invalid then terminate the process.

 

b) If the reference is valid then the page has not been yet brought into main memory.

 

3.   Find a free frame.

 

4.   Read the desired page into the newly allocated frame.

 

5.   Reset the page table to indicate that the page is now in memory.

 

6.   Restart the instruction that was interrupted .

 

Pure demand paging

 

Never bring a page into memory until it is required. We could start a process with no pages in memory.

v When the OS sets the instruction pointer to the 1st instruction of the process, which is on the non-memory resident page, then the process immediately faults for the page.

 

v After this page is bought into the memory, the process continue to execute, faulting as necessary until every page that it needs is in memory.

 

Performance of demand paging

 

Let p be the probability of a page fault 0  p  1

 

Effective Access Time (EAT)

 

EAT = (1 p) x  ma + p x  page fault time.

 

Where ma  memory access, p  Probability of page fault (0= p = 1)

 

v The memory access time denoted ma is in the range 10 to 200 ns.

 

v If there are no page faults then EAT = ma.

 

v To compute effective access time, we must know how much time is needed to service a page fault.

 

v A page fault causes the following sequence to occur:

 

1.   Trap to the OS

 

2.   Save the user registers and process state.

 

3.   Determine that the interrupt was a page fault.

 

4.   Check whether the reference was legal and find the location of page on disk.

 

5.   Read the page from disk to free frame.

 

a.   Wait in a queue until read request is serviced.

 

b.   Wait for seek time and latency time.

 

c.   Transfer the page from disk to free frame.

 

6.   While waiting ,allocate CPU to some other user.

 

7.   Interrupt from disk.

 

8.   Save registers and process state for other users.

 

9.   Determine that the interrupt was from disk.

 

10.  Reset the page table to indicate that the page is now in memory.

 

11.            Wait for CPU to be allocated to this process again.

 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Operating Systems : Storage Management : Virtual Memory |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.