The life and times

Post on 29-Jun-2015

131 Views

Category:

Education

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

virtual memory desin

Transcript

COMPUTER SCIENCE AND DATA PROCESSINGDEPARTMENT OF MATHEMATICSIIT KHARAGPUR

Virtual Memory

Abir Naskar13MA60R21

• Why virtual memory?

• Motivations.

• Memory hierarchy.

• Cache and Virtual memory.

• Paging.

• References.

OUTLINE

1

• Extension of main memory.

• Secondary storage is used.

• Combination of hardware and software.

• Usually very large.

• Working set of pages resides in main memory, others are in secondary memory.

VIRTUAL MEMORY

2

• Main memory is expensive.

• Main memory size is less.

• All program are not active.

• Multiprogramming environment.

• Time sharing.

• Allow OS to share memory.

• Protect program from each other.

WHY VIRTUAL MEMORY

3

• We use main memory as a cache of disk memory.- address space of process can exceed physical memory size.

• Simplify memory management.- only active code and data is actually in memory.

• Provide protection.- one process can’t interfere with another.

MOTIVATION

4

LEVELS IN MEMORY HIERARCHY

Size 32B 32KB-4MB 128MB 30GB

Speed 3ns 6ns 60ns 8ms

5

SYSTEM WITH PYHSICAL MEMORY ONLY

Address generated by CPU point directly to byte in physical memory.

Example: Cray machines, early PCs, embedded systems etc.

6

SYSTEM WITH VIRTUAL MEMORY

o Hardware converts virtual address to physical addresses via an OS-managed look-up table (page table).

o Example : modern PCs, workstations, servers etc.

7

CACHE MEMORY VIRTUAL MEMORY

Is a hardware or processor Is simulated on hard drive maintained by OS

Data reads in unit called “block” Data reads in unit called “pages”

Stores memory access by CPU Storage swapping between active storage and hard disk

Reduces the frequency that the CPU must wait for data from the main memory

Reduces the amount of physical storage access that is required

Performance-wise faster Performance-wise slower

CACHE MEMORY VS VIRTUAL MEMORY

8

• It is a Memory Management Technique in which the memory is divided into fixed size pages.

• Paging is used for faster access of data.

• Paging allows the physical address space of a process to be noncontiguous.

• A page is a sequence of N bytes where N is a power of 2.

• Page size should be high enough to amortize the high access time, and page fault rate is small.

• These days, page sizes are at least 4KB.

• If 1Mb RAM, then 1MB/4KB=256 pages.

PAGING

9

• Virtual address contains virtual page number and page offset.

• The number of pages addressable with virtual address is virtually unlimited where number of pages addressable with physical address is limited.

• Mapping from virtual to a physical address.

ADDRESS MAPPING

10

• A data may be or may not be present in main memory- if not present then page fault occur.

• OS takes control when the valid bit is 0.* OS creates pages for all the process in the disk.* It also creates a data structure to record where each virtual page is stored in the disk.* Another data structure to track which process and virtual address use physical page.

PAGE FAULT

11

• Find a free frame to store a desire page.* If there is free frame use it.* Otherwise use a page replacement algorithm to find a victim page.* Write the victim page on disk and change the page and page table accordingly.

• Read the desired page into free frame and change the page and page table.

• Restart the user process.

• Some page replacement algorithm: FIFO replacement, Least Recently Used replacement, Least Frequently Used replacement etc.

PAGE REPLACEMENT

12

13

• Page table is a data structure to store the mapping between virtual address and physical address.

• Used to translate logical to physical addresses.

• Page table entries: Address: pointer to the location of page in memory.Valid bit: where page is pointed.Dirty bit: set if at least one word of the page is modified.Referenced bit: set if page has been referenced with either read or write.protection bit: used to restrict access, like read only, system only access.

PAGE TABLE

• Applications run slower.

• It takes more time to switch between applications.

• Less hard drive space for your use.

DISADVANTAGES

14

• Stallings W. (2006): “Operating Systems: Internals and Design Principles (7th Edition)”. prentice hall.

• Tanenbaum A. S. (2013): “Modern Operating System (3rd edition)”,Pearson Education, pp.175-247.

• Cragon, Harvey G. (1996). Memory Systems and Pipelined Processors. Jones and Bartlett Publishers.ISBN 0-86720-474-5.

• URL: http://windows.microsoft.com/en-us/windows/what-is-virtual-memory#1TC=windows-7

• URL: http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Memory/virtual.html

REFERENCES

15

Thank you…

top related