Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 300 – Lecture 22 Intro to Computer Architecture / Assembly Language Virtual Memory.

Similar presentations


Presentation on theme: "CS 300 – Lecture 22 Intro to Computer Architecture / Assembly Language Virtual Memory."— Presentation transcript:

1 CS 300 – Lecture 22 Intro to Computer Architecture / Assembly Language Virtual Memory

2 Homework Questions!

3 The Bad Old Days Applications were directly coupled to the physical memory of the computer. If you wanted to run something, you would load the program you want and run it until it stops, then load a new program. Each program used the same physical memory addresses.

4 The Worse Old Days The original PCs were based on an architecture with no memory management at all. The solution was a "segmented" memory design. This pervaded the original PC architecture (hardware AND software). Even though segments allowed bigger programs to run they didn't prevent applications from interfering with each other. Nobody cried the day DOS died. Finally, with the Pentium, real memory management was possible!

5 About Virtual Memory Virtual Memory is another level of caching that sits between the disk and the main memory. While cache is exclusively a hardware issue, VM is handled in both hardware and operating system. That is, many of the things that are done in hardware in the cache can be addressed in software in the VM context.

6 Virtual Memory Issues What problems are virtual memory hardware trying to solve? * Multiple programs running at once * Limited supply of physical memory * Hardware enforcement of capabilities (security) * Safe sharing among applications * Ability to "route around" hardware faults in physical memory

7 VM Ideas Memory is divided into "pages". Pentium uses 1K words (4k bytes) per page. Addresses in your code are "virtual" – these are turned into physical addresses by a page table. The OS is responsible for the page table. ALL addresses are translated through this table (really indirection) The page table (or segment table) has other info: privileges, "Present" bit. The "swap file" is where VM pages are parked when rolled out of memory

8 Big Ideas in VM Enforce privileges in hardware – keep user code from accessing devices or other things that would allow processes to interfere with each other. Read-only pages: prevent immutable data from accidental modification Copy on write: allow pages to be shared or live outside swap space if not written on. Protection: use VM to detect conditions like stack overflow cheaply The page table defines the amount of memory available to a process.

9 The TLB Bad news: every memory access needs to go through the page table Good news: we can cache page table information so that there's no overhead to most address translation. Yet another cache is used to keep address translation from going too slow.

10 How Big is the Page Table? Pentium: 32 bit address – 12 for the address in the table so that leaves 20 bits (1 million). That means a page table would be > 4 megabytes! To fix this problem, the Pentium uses a two level table (page table of page tables)

11 Pentium Paging

12 Page Faulting Anytime an instruction references memory that is "paged out" (this is what the "P" bit is for in the page table) you have to stop the program and wait for a disk read. This is MUCH more expensive than a cache miss! This is an interrupt, similar to an IO interrupt Poor program performance is usually a result of too many page misses.


Download ppt "CS 300 – Lecture 22 Intro to Computer Architecture / Assembly Language Virtual Memory."

Similar presentations


Ads by Google