computer organization cs 147 prof. lee azita keshmiri
Post on 21-Dec-2015
220 views
TRANSCRIPT
![Page 1: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/1.jpg)
Computer Organization
Cs 147 Prof. Lee
Azita Keshmiri
![Page 2: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/2.jpg)
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.
![Page 3: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/3.jpg)
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.
![Page 4: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/4.jpg)
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.
![Page 5: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/5.jpg)
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
![Page 6: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/6.jpg)
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.
![Page 7: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/7.jpg)
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 6page0Page 2
Page 0Page 1Page 2Page 3Page
Page 5Page 6
![Page 8: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/8.jpg)
Virtual Memory
Memory that a single process “sees” - for example: 4 GB/process
Real/physical memory
Process 1
Process 2
![Page 9: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/9.jpg)
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.
![Page 10: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/10.jpg)
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.
![Page 11: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/11.jpg)
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.
![Page 12: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/12.jpg)
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
![Page 13: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/13.jpg)
One possible memory configuration for the Relatively Simple CPU
Address Space Physical memoryPage F
. . .
Page 2
Page 1
Page 0
Frame 3
Frame 2
Frame 1
Frame 0
![Page 14: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/14.jpg)
frames Physical memory is divided into
non overlapping frames. the size of each frame is the same
as the size of one page.
![Page 15: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/15.jpg)
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.
![Page 16: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/16.jpg)
MMU configuration within the memory hierarchy
CPU MMU Physical Memory
SwapDisk
logicaladdress
Physical
address
control signals
![Page 17: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/17.jpg)
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.
![Page 18: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/18.jpg)
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.
![Page 19: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/19.jpg)
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.
![Page 20: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/20.jpg)
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.
![Page 21: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/21.jpg)
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.
![Page 22: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/22.jpg)
Memory management unit A memory management unit maps
the logical addresses issued by the processor to their corresponding physical addresses.
![Page 23: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/23.jpg)
Memory management unit The memory management unit
uses page tables and translation look aside buffers to keep track of which frame corresponds.
![Page 24: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/24.jpg)
Page tables
Virtual page Hash table1 entry perPage frame
Full table:1 entry Per page
Page frame #index
hash
![Page 25: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/25.jpg)
Conversion of logical address to physical address using segmentation
segment offset
Segment table
compare
+
Out of bounds
Error (if offset >= size)
Physical memory address
Fault(if not inmemory)
Logical Address:
size
Address ofStart of segment
![Page 26: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/26.jpg)
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.
![Page 27: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/27.jpg)
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.
![Page 28: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/28.jpg)
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.
![Page 29: Computer Organization Cs 147 Prof. Lee Azita Keshmiri](https://reader036.vdocument.in/reader036/viewer/2022062313/56649d595503460f94a3a08e/html5/thumbnails/29.jpg)
THE END