Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Organization Cs 147 Prof. Lee Azita Keshmiri.

Similar presentations


Presentation on theme: "Computer Organization Cs 147 Prof. Lee Azita Keshmiri."— Presentation transcript:

1 Computer Organization Cs 147 Prof. Lee Azita Keshmiri

2 Virtual memory What is virtual memory? - A memory management unit that swaps data in and out of physical memory. - virtual memory makes it appear to the CPU that there is more physical memory than is actually presents.

3 Virtual Memory How does virtual memory works? - Virtual memory uses auxiliary storage, such as a disk, to expand the memory space available to the processor. To understand how virtual memory works, compare it to cache memory.

4 Cache memory A cache memory works by moving data to and from physical memory. When the CPU request data that is stored in cache, it receives this data faster than if it had to retrieve the data from physical memory.

5 Virtual memory and physically indexed caches Cache page frames. notion of bin -region of cache that may contain cache blocks from a page. - random vs careful mapping -selection of physical page frame dictates cache index. - overall goal is to minimize cache misses

6 Virtual memory A virtual memory system may use paging or segmentation. A paging system moves frames of fixed size between physical memory and virtual memory.

7 Virtual Memory Organization The virtual address space is divided into pieces of the same size Main memory is divided into pieces of the same size as pages called page frames. real memory virtual address space Page Page 6 page0 Page 2 Page 0 Page 1 Page 2 Page 3 Page Page 5 Page 6

8 Virtual Memory Memory that a single process “sees” - for example: 4 GB/process Real/physi cal memory Process 1 Process 2

9 memory management unit (MMU) A memory management unit moves data between physical memory and some slower storage device, usually a disk. This storage area may be referred to as a swap disk or swap file, depending on its implementation.

10 Paging In paging, the entire range of logical addresses those addresses that can be output by the CPU, is divided into blocks called pages. Each page is the same size. each logical address takes exactly one page.

11 Paging -1 Paging moves pages from the swap disk to frames of the physical memory so data can be accessed by the processor. Any page can occupy any frame. A page is small enough to fit in main memory.

12 Practical paging: Segmentation Based on the observation the most processes use only a small portion of the 4 GB addr space. Segmentation: partition the address space into large manageable chunks. Segment # page # offset Phy Addr. Index 4 Segment table page table

13 One possible memory configuration for the Relatively Simple CPU Address Space Physical memory Page F. Page 2 Page 1 Page 0 Frame 3 Frame 2 Frame 1 Frame 0

14 frames Physical memory is divided into non overlapping frames. the size of each frame is the same as the size of one page.

15 Page fault If the data is not located in physical memory,it generate a page fault and moves the page from the swap disk to a frame. - removes another page if necessary.

16 MMU configuration within the memory hierarchy CPU MMU Physical Memory Swap Disk logical address Physica l address control signals

17 Memory Hierarchy Memory is used to store programs and data. The lowest level of the memory hierarchy is a small, fast and costly memory called cache, usually implemented by static RAM chips. - primary Cache is located on the CPU chip. - Secondary cache is placed between the primary cache and main memory.

18 Memory Hierarchy(cont) Main Memory can be built by tens of megabytes at a reasonable cost. The affordable size is still small compared to the demands of very large programs.

19 Memory hierarchy The memory hierarchy of most computer systems includes not only physical memory, but also cache and virtual memory. Cache memory is a high-speed memory situated between the CPU and physical memory. - one level of cache is often located within the CPU chip.

20 Segmentation Segmentation is another method of allocating memory that can be used instead of or in conjunction with paging. A program is divided into several segments, each of which is a self- contained unit, such as a subroutine or data structure.

21 Segmentation-1 A segmented memory management unit (MMU) includes a segment table to keep track of the segments resident in memory. Since a segment can start at one of many addresses and can be of any size. each segment table entry must include the start address and segment size.

22 Memory management unit A memory management unit maps the logical addresses issued by the processor to their corresponding physical addresses.

23 Memory management unit The memory management unit uses page tables and translation look aside buffers to keep track of which frame corresponds.

24 Page tables Virtual page Hash table 1 entry per Page frame Full table: 1 entry Per page Page frame # index hash

25 Conversion of logical address to physical address using segmentation segmentoffset Segment table compare + Out of bounds Error (if offset >= size) Physical memory address Fault (if not in memory) Logical Address: size Address of Start of segment

26 Internal fragmentation In the paged memory implementation, each page is of size 4k. A program of size 4k+1 would require the memory management unit (MMU) to allocate two pages of memory, even though the second page would use only one of its 4k locations. This is referred to as internal fragmentation.

27 Protection bits A preferable option is to protect the segment or page, rather than individual locations. This produces the desired memory protection at an acceptable cost in terms of overhead. To accomplish this, protection bits are added to each entry in the segment or page table.

28 Page directory The Pentium microprocessor can use either segmentation or paging. the windows NT virtual memory manager uses paging. The 10 high-order bits of the 32-bit virtual address select an entry in the page directory, which is stored in physical memory.

29 THE END


Download ppt "Computer Organization Cs 147 Prof. Lee Azita Keshmiri."

Similar presentations


Ads by Google