Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 9 Virtual Memory Bernard Chen 2007 Spring.

Similar presentations

Presentation on theme: "Chapter 9 Virtual Memory Bernard Chen 2007 Spring."— Presentation transcript:

1 Chapter 9 Virtual Memory Bernard Chen 2007 Spring

2 Virtual Memory Only part of the program needs to be in memory for execution Logical address space can therefore be much larger than physical address space Allows for more efficient process creation Virtual memory can be implemented via: Demand paging Demand segmentation

3 Advantages A program no longer be constrained by the amount of physical memory that is available Since each user program could take less physical memory, more programs could run at the same time Less I/O would be needed to load or swap each user program into memory, so it will be faster

4 Virtual Memory

5 Demand Paging In stead of loading whole program into memory, demand paging is an alternative strategy to initially load pages only as they are needed Lazy Swapper: Pages are only loaded when they are demanded during program execution Swapper that deals with pages is a pager

6 Transfer of a page memory to continuous disk space

7 Demand paging basic concepts When a process is to be swapped in, the pager guesses which pages will be used before the process is swapped out again. Instead of swapping in a whole process, the pager brings only those necessary pages into memory

8 Valid Valid-Invalid Bit With each page table entry a valid–invalid bit is associated (v=> in-memory, i =>not-in-memory) Initially valid–invalid bit is set to i on all entries During address translation, if valid–invalid bit in page table entry is i => page fault

9 Valid Valid-Invalid Bit Example


11 Page Fault


13 Performance of Demand Paging Page Fault Rate 0 ≤p≤1.0 if p= 0 no page faults if p= 1, every reference is a fault Effective Access Time (EAT)= (1-p)*ma + p*page fault time

14 Performance of Demand Paging

15 If we want performance degradation to be less than 10%, we need 220 > 200+7,999,800*p 20>7,999,800*p P<0.0000025 It is important to keep the page-fault rate low in a demand-paging system

16 9.4 Page Replacement What if there is no free frame? Page replacement –find some page in memory, but not really in use, swap it out In this case, same page may be brought into memory several times

17 Basic Page Replacement

18 Page Replacement

19 Page Replacement Algorithms Goal: Want lowest page-fault rate Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults on that string In all our examples, the reference string is 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5

20 FIFO When a page must be replaced, the oldest page is chosen In all our examples, the reference string is 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 3 frame 4 frame

21 FIFO Algorithm

Download ppt "Chapter 9 Virtual Memory Bernard Chen 2007 Spring."

Similar presentations

Ads by Google