Presentation is loading. Please wait.

Presentation is loading. Please wait.

ITEC 352 Lecture 25 Memory(3). Review Questions RAM –What is the difference between register memory, cache memory, and main memory? –What connects the.

Similar presentations


Presentation on theme: "ITEC 352 Lecture 25 Memory(3). Review Questions RAM –What is the difference between register memory, cache memory, and main memory? –What connects the."— Presentation transcript:

1 ITEC 352 Lecture 25 Memory(3)

2 Review Questions RAM –What is the difference between register memory, cache memory, and main memory? –What connects the different types of memory together? –What are some of the different ways to handle what is in the cache?

3 Memory (3) Objectives Cache memory Intro to virtual memory

4 Memory (3) Performanc e of a cache Assume a program (instructions) is loaded into the memory from address 0 to 57. Also assume: cache access time: 80 ns and memory access time: 2500 ns. What is the performance when using a cache. 0 - 16 Memory address range Memory 17 - 33 34-40 41-57 Cache

5 Memory (3) Performanc e of a cache What is the memory address of the first instruction accessed? –Address: 0 Is this in the cache? –Initially, cache is empty. Hence, no! So what do you do? –Depends on the policy 0 - 16 Memory address range Memory 17 - 33 34-40 41-57 Cache

6 Memory (3) Performanc e of a cache As the data is not in the cache, the block 0-16 is loaded into the slot1 of the cache. The next instruction is at address 1. –Is this in the cache? –Yes – so the next 15 instructions are in the cache. 0 - 16 Memory address range Memory 17 - 33 34-40 41-57 Cache

7 Memory (3) Performanc e of cache Hence: EventLocation Time 1 miss 0 2500 ns 15 hits 1-16 80ns X 15 …

8 Memory (3) Hit Ratios and Effective Access Times Hit ratio and effective access time for single level cache: Hit ratios and effective access time for multi-level cache:

9 Memory (3) Multilevel caches As size of ICs have increased, packing density also has increased. –Multilevel caches have been developed Fastest level L1 is on the chip. –Usually data and instructions are kept separate on this cache. Called split cache. Level L2 and L3 are slower than L1 and are unified caches.

10 Memory (3) Question Lets say there are 10000 memory references to execute a process. –90 cause L1 misses and of these 10 cause L2 misses. –Let L1 hit time: 5 ns (this is the time to access a memory location if it is in the cache). –Let L2 hit time: 20 ns –Let the L2 miss time: 100 ns (time to access memory in the main memory). What is the effective access time to access a memory?

11 Memory (3) Summary so far … We have seen different types of memory elements and gone up the hierarchy of memory. –We have developed RAM, ROM, Registers and looked at Caches. Next: we will see how programs that we develop are allocated memory. Some terminology: –Process: any program in execution is called a process. E.g., A java program that you write is simply a program, unless you execute it. During its execution it becomes a process. There can be multiple processes of the same program.

12 Memory (3) Memory Allocation Two problems in memory allocation. –Processes must not have conflicts in memory they use. (must have separate memory). E.g., you wouldn’t want memory used by your process to be overwritten by that of another user. Solution: Relocatable Code –Small amount of physical memory (RAM) must be used to execute a large number of processes –(or execute large processes each of which exceed the size of RAM) –Solution: Virtual Memory.

13 Memory (3) Relocatable code and Virtual Memory Relocatable assembly code: processes must be able to reside in any portion of the physical memory. –Why ? Consider an operating system, where all executions of Microsoft Word must only reside at address 0x800000. What would happen ? –Hence, compiled and assembled programs do not have fixed addresses allocated to them.  Virtual memory: use hard disk as an extension for RAM.  Intuition: processes are allocated memory in a special portion of the hard disk. They are loaded into RAM only when they are executing on the CPU

14 Memory (3) Relocatable code Program binary code, such that the addresses of the process address space can be changed dynamically. I.e. it doesn’t map to main memory It has it’s own memory space Operating system replaces with what it deems appropriate

15 Memory (3) Relocatable Code #include … int main() { int x = 10; return x; } : push %ebp BINARY CODE : mov %esp,%ebp : sub $0x8,%esp … : ret : nop 0x0804867c : push %ebp 0x0804867d : mov %esp,%ebp 0x0804867f : sub $0x8,%esp … 0x0804869c : ret 0x0804869d : nop Compiler + assembler Compiler generates relocatable code: e.g., return instruction is 32 bytes away from beginning of code segment When process is created. The process is given addresses by OS Address called as logical address Address binding: binding each logical address to a location in physical memory Linking and loading

16 Memory (3) Relocatable Code #include … int main() { int x = 10; return x; } : push %ebp BINARY CODE : mov %esp,%ebp : sub $0x8,%esp … : ret : nop 0x0804867c : push %ebp 0x0804867d : mov %esp,%ebp 0x0804867f : sub $0x8,%esp … 0x0804869c : ret 0x0804869d : nop Compiler + assembler Compiler generates relocatable code: e.g., return instruction is 32 bytes away from beginning of code segment When process is created. The process is given addresses by CPU. Address called as logical address Address binding: binding each logical address to a location in physical memory Linking and loading

17 Memory (3) Using a HD as memory © Image from Silberschatz and Galvin

18 Three types of memory addresses C program Compiler/Assembler Binary code (relocatable addresses)\ Aka linear addresses When program is Executed. CPU generated Logical Addresses Also called Virtual address Loader Logical Address Bound to Physical memory address Three types of addresses: linear address (addresses in compiled binaries), logical address (address in the virtual memory) and physical address (address in the RAM when a program is loaded).

19 Dynamic Relocation using relocation register: mapping logical to physical address. © Image from Silberschatz and Galvin

20 Memory (3) Virtual Memory (2) When a process is executed, the OS allocates memory for the process on the disk (usually 4 GB of memory is allocated). –This includes a code segment, data segment and program stack. –In UNIX, we usually call this portion of the disk as swap partition. Advantage: Process memory is not tied to the amount of RAM. However, for a CPU to execute a process, the process must be in the physical memory. –Hence, OSes provide methods to map process address space on virtual memory (called logical memory) to physical memory (memory addresses in RAM).

21 Memory (3) Summary Cache access Virtual memory


Download ppt "ITEC 352 Lecture 25 Memory(3). Review Questions RAM –What is the difference between register memory, cache memory, and main memory? –What connects the."

Similar presentations


Ads by Google