virtual memory by jemini islam. what is virtual memory virtual memory is a memory management system...

30
Virtual Memory BY JEMINI ISLAM

Post on 15-Jan-2016

231 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Virtual Memory

BYJEMINI ISLAM

Page 2: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

What is Virtual Memory

Virtual memory is a memory management system that gives a computer the appearance of having more main memory than it really has.

Page 3: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

ReasonsReasons for usingfor using virtualvirtual memorymemory To free programmers from the need to carry To free programmers from the need to carry

out storage allocation and to permit efficient out storage allocation and to permit efficient sharing of memory space among different sharing of memory space among different users.users.

To make programs independent of the To make programs independent of the configuration and the capacity of the memory configuration and the capacity of the memory systems used during their execution.systems used during their execution.

To achieve the high access rates and low cost To achieve the high access rates and low cost per bit that is possible with a memory per bit that is possible with a memory hierarchy.hierarchy.

Page 4: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

2 Main Advantages of Virtual Memory 1. Main memory is used more

efficiently

2.Programs that are bigger than main memory can still be executed.

Page 5: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Implementation of Virtual Memory System: Paging: - Fixed-size blocks Segmentation:- Variable size blocks Paged Segmentation: Combination of

two systems.

Page 6: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Paging

Paging systems use fixed-length blocks called pages pages and assign them to fixed regions of physical memory called page frames.page frames.

Page 7: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Page Table:

4

6

2

5

Frame NumberPage Number

0

1

2

3

Page Table

Page 8: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Pages:

Example: Each page has the same length, typically a power of 2.

Code Data

Page 9: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Advantage of Paging: The main advantage of paging is that

memory allocation is greatly simplified, since an incoming pages can be assigned to any available page frame which is also known as fully fully associative.associative.

Page 10: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Memory Mapping and Page Table:

Memory Mapping: With virtual memory, the CPU produces virtual addresses that are translated by combination of hardware and software to physical addresses, which access main memory. This is called memory mapping or address translation.

Page Table: Translation between virtual addresses and physical addresses is done via a page table.

Page 11: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Virtual page number

Page offset

Pagetable

Mainmemory

The Mapping of a Virtual Addressto a Physical Address Via a PageTable

Virtual address

Physical Address

Page 12: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Techniques for Fast Address Translation: To reduce address translation time,

computers use a cache dedicated to these address translation, which is called a translation look-aside buffer or TLB.

Page 13: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Structure of a Virtual Memory System :

TLBMemoryMap

Virtual Block Address

Logical(virtual)Address

PhysicalAddress

Displacement

Physical blockAddress

Main Memory

Secondary Memory

Page 14: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Representative Organization of a Page Table :

Page Page Presence Change AccessAddress Frame bit P bit C rightsA 0 1 0 R, X C D6C7T9 0 R, W, XE 24 1 1 R, W, XF 16 1 0 R

Page 15: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Selecting Page Size:

Choosing a page size is a question of balancing forces that favor a larger page size versus those favoring a smaller size.

They both have some advantages and disadvantages:

Page 16: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Advantage of Choosing Large Page Size: The size of the page table is inversely

proportional to the page size: Memory can therefore be saved by making the

pages bigger Transferring larger pages to or from

secondary storage, possibly over a network, is more efficient than transferring smaller pages.

Page 17: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Advantage Of Choosing Small Page Size : The main reason for choosing smaller

page is conserving storage. A small page size will result in less wasted storage when a contiguous region of virtual memory is not equal in size to a multiple of the page size. The term for this unused memory in a page is internal fragmentation.

Page 18: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Page Replacement Policies: 3 major page replacement policies: FIFO

LRU

OPT

Page 19: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

FIFO

FIFO(first in first out) : With FIFO, the oldest page in memory is selected for replacement

Example: 2 3 2 1 5 2 4 5 3 2 5 2

2 2 *2 2 5 5 5 *5 3 3 3 3

3 3 3 3 2 2 2 2 *2 5 5

1 1 1 4 4 4 4 4 2

Page 20: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

LRU: (least recently used) LRU Policy- a policy that selects the

page that has gone unused for the longest period of time.

2 3 2 1 5 2 4 5 3 2 5 2

2 3 *2 1 5 *2 4 *5 3 2 *5 *2

2 3 2 1 5 2 4 5 3 2 5

3 2 1 5 2 4 5 3 3

Page 21: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

OPT(optimal replacement policy) In this policy we will replace the

memory with the page address which we will not use in the near future.

Page 22: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Examples of OPT :

2 3 2 1 5 2 4 5 3 2 5 2

2 2 *2 2 2 *2 4 4 4 2 2 *2

3 3 3 3 3 3 3 *3 3 3 3

1 5 5 5 *5 5 5 *5 5

Page 23: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Segmentation : Segment : A segment is a set of

logically related contiguous words generated by a compiler or a programmer.

Segmentation : A memory management technique that allocates main memory by segments is called segmentation.

Page 24: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Size of Segments : Variable size blocks are called

segments. Segments size varies. The largest segment supported on any

machine ranges from 2^16 bytes up to 2^32 bytes

Code Data

Page 25: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Segment Table:

The physical addresses assigned to the segments are maintained in a memory map called a segment table.

Page 26: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Segment-Table Entry Segment-Table0 1 2 3 8 18 33

47

Tag

PresenceBit P

Segment size ZPhysical address S

Page 27: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

External Fragmentation:

External Fragmentation: It happens because of unused pieces of main memory.

Page 28: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Paged Segments : Combination of paging and

segmentation. This is done by dividing each segment

into pages. A word then has a logical address with

3 components- Segment Address Page Address Line Address

Page 29: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

Advantage of Paged Segments:

It eliminates the need to store the segment in a contiguous region of main memory.

Page 30: Virtual Memory BY JEMINI ISLAM. What is Virtual Memory Virtual memory is a memory management system that gives a computer the appearance of having more

References Dos Reis, Anthony J. Assembly Language And

Computer Architecture Using C++ And Java. Hennessy, John and Patterson, David. Computer

Organization and Design. San Mateo,California : Morgan Kaufmann, 1994.

Hennessy, John and Patterson, David. Computer Architecture A Quantitative Approach. Sanfrancisco : Morgan Kaufmann, 1996.

Hennessy, John and Patterson, David. Computer Architecture A Quantitative Approach : Morgan Kaufmann, 1990.

Hayes, John. Computer Architecture And Organization. McGraw-Hill Book Company, 1988.