Download presentation
Presentation is loading. Please wait.
Published byLeo Short Modified over 9 years ago
2
Ch7d- 2 EE/CS/CPE 3760 - Computer Organization Seattle Pacific University Individual Space Every process wants its own space Ideally, it would like the entire computer to itself Sharing the computer’s memory creates problems Sometimes a program will be at location 4000, sometimes at location 5888820, etc. 7.4 Use Virtual Memory to fool each process to thinking that it starts at location 0 CPU uses virtual addresses - Start the program at virtual page 0, even if it’s not physical page 0 Each process must have an individual page table to make this work Every virtual page 0 must point to a different physical page, and so on
3
Ch7d- 3 EE/CS/CPE 3760 - Computer Organization Seattle Pacific University Example VPNValidPPN/ (index)BitDisk address 00000011001 0000010sector 5000... 00001011100 0000110sector 4323… 00010011011 00010110101 0001100sector 1239... 00011110001 Page Table for process A: VPNValidPPN/ (index)BitDisk address 00000010010 00000110000 00001010011 00001111100 0001000sector 2311... 0001010sector 158... 0001100sector 555... 00011110100 Page Table for process B: 7.4 Virtual page 000000 (process A) points to physical page 1001. Virtual page 000000 (process B) points to physical page 0010. The processes both can start at location 000000, but have different data. Note: Physical page 1100 is shared.
4
Ch7d- 4 EE/CS/CPE 3760 - Computer Organization Seattle Pacific University Protection Using Virtual Memory 7.4 We want to protect different processes from each other Can’t read or write to any other process’s memory, unless specifically allowed Providing separate page tables fixes this problem Each process can only access pages through its page table As long as the page table doesn’t point to pages belonging to other processes, no problem Since only the OS can write the page tables, the system is safe
5
Ch7d- 5 EE/CS/CPE 3760 - Computer Organization Seattle Pacific University Protection Example VPNValidPPN/ (index)BitDisk address 00000011001 0000010sector 5000... 00001011100 0000110sector 4323… 00010011011 00010110101 0001100sector 1239... 00011110001 Page Table for process A: VPNValidPPN/ (index)BitDisk address 00000010010 00000110000 00001010011 00001111100 0001000sector 2311... 0001010sector 158... 0001100sector 555... 00011110100 Page Table for process B: 7.4 How can process A access process B’s V.P. 000010? Note: Since physical page 1100 is shared, protection is violated. None of process A’s V.P. point to Physical page 0011 - Impossible to to access it!
6
Ch7d- 6 EE/CS/CPE 3760 - Computer Organization Seattle Pacific University Shooting Ourselves in the Foot 7.4 Virtual Memory Access Look up page number in page table Access memory Each memory access becomes two accesses Even for addresses stored in the cache Solution: Cache the page table entries in a special cache The Translation Lookaside Buffer (TLB) is just a cache that holds recently accessed page table entries A TLB hit means that we don’t have to actually look in the page table
7
Ch7d- 7 EE/CS/CPE 3760 - Computer Organization Seattle Pacific University TLB Design 7.4 We want the TLB to have a high hit rate Fortunately, pages are huge, providing super-high locality TLB usually only has a small number of entries (i.e. 64) and is fully-associative Typical hit rates are 98.0 to 99.9% The TLB should store anything needed from the page table Physical page number Valid bit, Dirty bit Warning: TLB can violate protection after a process switch Flush the TLB on each process switch
8
Ch7d- 8 EE/CS/CPE 3760 - Computer Organization Seattle Pacific University Virtual Memory Benefits 7.4 Virtual Memory frees the programmer from many issues Large programs can run in smaller systems It doesn’t matter what else is running on the system, all programs start at a virtual address of zero and can access the entire address space Virtual memory protects different processes from each other
9
Ch7d- 9 EE/CS/CPE 3760 - Computer Organization Seattle Pacific University Evidence of Virtual Memory at Work 7.4 Thrashing If a program is just too big, it will constantly page fault to read in new pages (and throw out ones it needs) Paging Out If a program has been sitting idle for a long time, it is likely that it will be completely paged out to disk When you return to the program, it will start out slow as it pages all of the memory back in Loading Bringing in a new program may require writing pages for an old one out to disk
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.