virtual memory ppts

15
VIRTUAL MEMORY Present by: - Manpreet Kaur

Upload: manpreetgrewal

Post on 29-Nov-2014

2.610 views

Category:

Education


5 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Virtual memory ppts

VIRTUAL MEMORYPresent by: -Manpreet Kaur

Page 2: Virtual memory ppts

CONTENTS

virtual memory Needs of virtual memory Importance of virtual memory Memory mapping Advantage of virtual memory Disadvantage of virtual memory Address space & memory space Page replacement algorithms FIFO LRU OPT

Page 3: Virtual memory ppts

VIRTUAL MEMORY

Virtual memory is a common part of operating system on desktop computers.

The term virtual memory refers to something which appears to be present but actually it is not.

He virtual memory technique allows users to use more memory for a program than the real memory of a computer.

Page frames

CPULogical page + x

Mapper

Virtual address

(1)

Not present

(4)Page frames

(3) Page frame + x

present

(5)

Secondary storage

Page 4: Virtual memory ppts

NEED OF VIRTUAL MEMORY

Virtual memory is a imaginary memory which we are assuming. If we have a material that exceed your memory at that time we need to use the concept of virtual memory.

virtual memory is temporary memory which is used along with the ram of the system.

Page 5: Virtual memory ppts

IMPORTANCE OF VIRTUAL MEMORY

When your computer runs out of physical memory it writes what it needs to remember to the hard disc in a swap file as virtual memory.

If a computer running Windows requires more memory/RAM then there is installed in the system to run a program, etc, it uses a small section of the hard drive for this purpose

Page 6: Virtual memory ppts

Memory Mapping Memory mapping is a

common concept in POSIX and Windows systems. It enables a process to map disk files to its address space, treating them as memory blocks rather than files.

the mapping consists of translating a disk location to a virtual

Page 7: Virtual memory ppts

ADVANTAGES OF VIRTUAL MEMORY

Allows processes whose aggregate memory requirement is greater than the amount of physical memory, as infrequently used pages can reside on the disk.

Virtual memory allows speed gain when only a particular segment of the program is required for the execution of the program.

This concept is very helpful in implementing multiprogramming environment.

Page 8: Virtual memory ppts

DISADVANTAGES OF VIRTUAL MEMORY

Applications run slower if the system is using virtual memory.

It Takes more time to switch between applications. Less hard drive space for your use. It reduces system stability.

Page 9: Virtual memory ppts

ADDRESS SPACE AND MEMORY SPACE

Virtual memory is the address used by the programmer and the set of such addresses is called address space.

An address in main memory is called a physical address. The set of such locations in main memory is called the

memory space. Thus the memory space consist of the actual main

memory locations directly addressable for processing.

Page 10: Virtual memory ppts

PAGE FRAME AND HIT RATIO

Page Frame: - The main memory is divided into fixed sized portions called page frame.

Hit Ratio: - The ratio of the total number of hit divided by the total CPU access to memory (i.e. hits plus misses) is called hit ratio.

Hit ratio=total number of hits total number of hits + total number of mis

Page 11: Virtual memory ppts

PAGE REPLACEMENT ALGORITHMS

In a computer operating system that uses paging for virtual memory management, page replacement algorithm decide which memory pages to page out. When a page of memory need to be allocated.

When a program starts execution, one or more pages are transferred into main memory.

Paging happens when a

page fault occurs.

Page 12: Virtual memory ppts

FIFO

hit hit hit

First in first out is very easy to implement The fifo algorithm select the page for replacement that has been in memory

the longest time The page to be removed is easily determined because its identification

number is at the top of the fifo stack. It has the disadvantage that under certain circumstances pages are removed

and loaded from memory too frequently.

p2*

p2*

p3

P3*

P5

p2

P3

P5

P4*

P3

P2*

p4

P3

p2*

p4

p5*

P2

p4

p5*

P2

p4

p5

P2

P1*

P5

p3*

p1

p2*

P3

P1

p2*

p3

1 2 3 4 5 6 7 8 9 10 11 12timeP2 p3 p2 p1 p5 p2 p4 p5 p3 p2 p5 p2

page

Page 13: Virtual memory ppts

LRU

The least recently used page replacement algorithm keeps track page uses over a short period of time.

The LRU algorithm can be implemented by associating a counter with every page that is n main memory.

p2*

p2*

p3

P3*

P5

p2

P3*

P5

P2

P3

P5*

P2

P3

P5

p4*

p2*

P5

P4

P2

p5*

p4

P2

P5

P1*

p2*

P5

P1

P2

p3*

P1

P2

p3*

1 2 3 4 5 6 7 8 9 10 11 12time

P2 p3 p2 p1 p5 p2 p4 p5 p3 p2 p5 p2

page

hit hit hit hit hit

Page 14: Virtual memory ppts

OPT

The optimal policy selects that page for replacement for which the time to the next reference is longest.

This algorithm result is fewest number of page faults.

p2

p2

p3

P2

P3

P5

P2

P3

P5

P2

P3

P5

P4

P3

p5

P4

P3

P5

P4

P3

p5

P2

P3

P5

P2

P3

P5

P2

p3

P1

P2

p3

1 2 3 4 5 6 7 8 9 10 11 12

P2 p3 p2 p1 p5 p2 p4 p5 p3 p2 p5 p2

hit hit hit hit hit

time

page

hit

Page 15: Virtual memory ppts