Presentation is loading. Please wait.

Presentation is loading. Please wait.

Virtual Memory Hakim Weatherspoon CS 3410 Computer Science

Similar presentations


Presentation on theme: "Virtual Memory Hakim Weatherspoon CS 3410 Computer Science"— Presentation transcript:

1 Virtual Memory Hakim Weatherspoon CS 3410 Computer Science
Cornell University [Weatherspoon, Bala, Bracy, McKee, and Sirer]

2 Where are we now and where are we going?
How many programs do you run at once? a) 1 b) 2 c) 3-5 d) 6-10 e) 11+

3 Big Picture: Multiple Processes
How to run multiple processes? Time-multiplex a single CPU core (multi-tasking) Web browser, skype, office, … all must co-exist Many cores per processor (multi-core) or many processors (multi-processor) Multiple programs run simultaneously

4 Processor & Memory CPU address/data bus... … routed through caches
… to main memory Simple, fast, but… CPU 0xfff…f 0x7ff…f Stack $$ Heap Data Text 0x000…0 Memory

5 Multiple Processes Q: What happens when another program is executed concurrently on another processor? CPU 0xfff…f 0x7ff…f Stack Stack $$ $$ Heap Heap CPU Data Data Text Text 0x000…0 Memory

6 Multiple Processes Q: Can we relocate second program? $$ $$ CPU CPU
0xfff…f 0x7ff…f Stack Stack $$ $$ Heap Heap CPU Data Data Text Text 0x000…0 Memory

7 Big Picture: (Virtual) Memory
Process 1 3 2 1 A B C Give each process an illusion that it has exclusive access to entire main memory D Process 2 3 2 1 E F G H

8 But In Reality… Process 1 Process 2 14 D 13 12 E 11 10 C 9 8 7 B G 6 H
5 Process 2 4 A 3 2 F 1 Physical Memory

9 How do we create the illusion?
14 D 13 12 Process 1 3 2 1 A E 11 B 10 C C 9 D 8 7 B G 6 H 5 Process 2 3 2 1 E 4 F A 3 G 2 H F 1 Physical Memory

10 How do we create the illusion?
14 D 13 12 Process 1 3 2 1 A E 11 B 10 C All problems in computer science can be solved by another level of indirection. – David Wheeler C 9 D 8 7 B G 6 H 5 Process 2 3 2 1 E 4 F A 3 G 2 H F 1 Physical Memory

11 How do we create the illusion?
14 D 13 12 Process 1 3 2 1 A E 11 B Map virtual address to physical address 10 C C 9 D 8 Virtual address Physical address 7 B Memory management unit (MMU) takes care of the mapping G 6 H 5 Process 2 3 2 1 E 4 F A 3 G 2 H F 1 Virtual Memory (just a concept; does not exist physically) Physical Memory

12 How do we create the illusion?
14 Process 1 wants to access data C D 13 12 Process 1 Process 1 thinks it is stored at addr 1 3 2 1 A E 11 B So CPU generates addr 1 10 C C 9 D This addr is intercepted by MMU 8 Virtual address B Physical address 7 G 6 MMU knows this is a virtual addr H 5 Process 2 3 2 1 E MMU looks at the mapping 4 F A 3 G Virtual addr 1 -> Physical addr 9 2 H Data at Physical addr 9 is sent to CPU F 1 Virtual Memory (just a concept; does not exist physically) And that data is indeed C!!! Physical Memory

13 How do we create the illusion?
14 D 13 12 Process 1 3 2 1 A E 11 B Map virtual address to physical address 10 C C 9 D 8 7 B Memory management unit (MMU) takes care of the mapping G 6 H 5 Process 2 3 2 1 E 4 F 3 G 2 H 1 Virtual Memory A F Physical Memory Disk

14 Big Picture: (Virtual) Memory
From a process’s perspective – Process only sees the virtual memory Contiguous memory Process 1 3 2 1 A B Hidden from Process C C D Physical Memory Virtual Memory

15 Big Picture: (Virtual) Memory
From a process’s perspective – Process only sees the virtual memory Contiguous memory No need to recompile - only mappings need to be updated Process 1 3 2 1 A B Hidden from Process C C D Physical Memory Virtual Memory

16 Big Picture: (Virtual) Memory
From a process’s perspective – Process only sees the virtual memory Contiguous memory No need to recompile - only mappings need to be updated C Process 1 3 2 1 A B Hidden from Process C D Physical Memory Virtual Memory

17 Big Picture: (Virtual) Memory
From a process’s perspective – Process only sees the virtual memory Contiguous memory No need to recompile - only mappings need to be updated When run out of memory, MMU maps data on disk in a transparent manner Process 1 3 2 1 A B Hidden from Process C D Physical Memory Virtual Memory C Disk

18 Next Goal How does Virtual Memory work?
i.e. How do we create the “map” that maps a virtual address generated by the CPU to a physical address used by main memory?

19 Next Goal (after spring break!)
How does Virtual Memory work? i.e. How do we create the “map” that maps a virtual address generated by the CPU to a physical address used by main memory?

20 Virtual Memory Agenda What is Virtual Memory?
How does Virtual memory Work? Address Translation Overhead Paging Performance


Download ppt "Virtual Memory Hakim Weatherspoon CS 3410 Computer Science"

Similar presentations


Ads by Google