Homework 2 Review Cornell CS 3410. Calling Conventions int gcd(int x, int y) { int t, a = x, b = y; while(b != 0) { t = b; b = mod(a, b); a = t; } return.

Slides:



Advertisements
Similar presentations
CS Spring 2014 Prelim 2 Review
Advertisements

1 CMPT 300 Introduction to Operating Systems Virtual Memory Sample Questions.
Procedure Calls Prof. Sirer CS 316 Cornell University.
Computer Architecture CSCE 350
CSC 4250 Computer Architectures December 8, 2006 Chapter 5. Memory Hierarchy.
How caches take advantage of Temporal locality
Review CPSC 321 Andreas Klappenecker Announcements Tuesday, November 30, midterm exam.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
1 Answers to Test 1, Question 1 The functions determines if a positive number is prime. It does this by checking if the number is lower than 4, if so it.
Answers to the VM Problems Spring First question A computer has 32 bit addresses and a virtual memory with a page size of 8 kilobytes.  How many.
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 24 Instructor: L.N. Bhuyan
CS 241 Section Week #12 (04/22/10).
1 Copyright © 2011, Elsevier Inc. All rights Reserved. Appendix B Authors: John Hennessy & David Patterson.
Paging Examples Assume a page size of 1K and a 15-bit logical address space. How many pages are in the system?
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 08 Main Memory (Page table questions)
Some VM Complications Extra memory accesses Page tables are huge
CMPE 421 Parallel Computer Architecture
Lecture 19: Virtual Memory
The Memory Hierarchy 21/05/2009Lecture 32_CA&O_Engr Umbreen Sabir.
Virtual Memory Expanding Memory Multiple Concurrent Processes.
CS399 New Beginnings Jonathan Walpole. Virtual Memory (1)
1 Virtual Memory Main memory can act as a cache for the secondary storage (disk) Advantages: –illusion of having more physical memory –program relocation.
Virtual Memory. Virtual Memory: Topics Why virtual memory? Virtual to physical address translation Page Table Translation Lookaside Buffer (TLB)
Lecture 40: Review Session #2 Reminders –Final exam, Thursday 3:10pm Sloan 150 –Course evaluation (Blue Course Evaluation) Access through.
Virtual Memory 1 1.
Chapter 91 Logical Address in Paging  Page size always chosen as a power of 2.  Example: if 16 bit addresses are used and page size = 1K, we need 10.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
1  2004 Morgan Kaufmann Publishers Chapter Seven Memory Hierarchy-3 by Patterson.
Lecture 17 Final Review Prof. Mike Schulte Computer Architecture ECE 201.
Virtual Memory Review Goal: give illusion of a large memory Allow many processes to share single memory Strategy Break physical memory up into blocks (pages)
Constructive Computer Architecture Virtual Memory: From Address Translation to Demand Paging Arvind Computer Science & Artificial Intelligence Lab. Massachusetts.
CSE 351 Caches. Section Feedback Before we begin, we’d like to get some feedback about section If you could answer the following questions on the provided.
COSC 3330/6308 Second Review Session Fall Instruction Timings For each of the following MIPS instructions, check the cycles that each instruction.
EECS 370 Discussion 1 Calvin and Hobbes by Bill Watterson.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
3/1/2002CSE Virtual Memory Virtual Memory CPU On-chip cache Off-chip cache DRAM memory Disk memory Note: Some of the material in this lecture are.
CS203 – Advanced Computer Architecture Virtual Memory.
Memory Hierarchy and Cache. A Mystery… Memory Main memory = RAM : Random Access Memory – Read/write – Multiple flavors – DDR SDRAM most common 64 bit.
1 Lecture 20: OOO, Memory Hierarchy Today’s topics:  Out-of-order execution  Cache basics.
W4118 Operating Systems Instructor: Junfeng Yang.
Memory Management & Virtual Memory. Hierarchy Cache Memory : Provide invisible speedup to main memory.
Memory: Page Table Structure
CS 140 Lecture Notes: Virtual Memory
Virtual Memory Chapter 7.4.
MIPS Assembly Language Programming
Tutorial Nine Cache CompSci Semester One 2016.
Memory COMPUTER ARCHITECTURE
CS2100 Computer Organization
CS161 – Design and Architecture of Computer
Sarah Diesburg Operating Systems CS 3430
Memory Hierarchy Virtual Memory, Address Translation
CS510 Operating System Foundations
Paging Examples Assume a page size of 1K and a 15-bit logical address space. How many pages are in the system?
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
CSCI206 - Computer Organization & Programming
FIGURE 12-1 Memory Hierarchy
CS241 Section: Week 10.
Sarah Diesburg Operating Systems CS 3430
MIPS Instructions.
Lecture 22: Cache Hierarchies, Memory
Direct Mapping.
Memory Hierarchy Memory: hierarchy of components of various speeds and capacities Hierarchy driven by cost and performance In early days Primary memory.
CS 140 Lecture Notes: Virtual Memory
Lecture 20: OOO, Memory Hierarchy
Lecture 20: OOO, Memory Hierarchy
Sarah Diesburg Operating Systems CS 3430
Sarah Diesburg Operating Systems CS 3430
Memory Management & Virtual Memory
Sarah Diesburg Operating Systems COP 4610
Virtual Memory 1 1.
Presentation transcript:

Homework 2 Review Cornell CS 3410

Calling Conventions int gcd(int x, int y) { int t, a = x, b = y; while(b != 0) { t = b; b = mod(a, b); a = t; } return a; } How many caller/callee-saved registers would you expect this C code to use? For each variable, would it make more sense to use a caller- or callee-saved register?

Calling Conventions int gcd(int x, int y) { int t, a = x, b = y; while(b != 0) { t = b; b = mod(a, b); a = t; } return a; } How many caller/callee-saved registers would you expect this C code to use? For each variable, would it make more sense to use a caller- or callee-saved register? 3 registers: 1 callee-saved register for t t is needed after the call to mod 2 caller-saved registers for a and b

Calling Conventions int gcd(int x, int y) { int t, a = x, b = y; while(b != 0) { t = b; b = mod(a, b); a = t; } return a; } Write the prologue for gcd().

Calling Conventions int gcd(int x, int y) { int t, a = x, b = y; while(b != 0) { t = b; b = mod(a, b); a = t; } return a; } Write the prologue for gcd(). addiu $sp, $sp, -28 sw $ra, 24($sp) sw $fp, 20($sp) sw $s0, 16($sp) addiu $fp, $sp, 24 addiu $t0, $a0, 0 addiu $t1, $a1, 0

Calling Conventions int gcd(int x, int y) { int t, a = x, b = y; while(b != 0) { t = b; b = mod(a, b); a = t; } return a; } Write the epilogue for gcd().

Calling Conventions int gcd(int x, int y) { int t, a = x, b = y; while(b != 0) { t = b; b = mod(a, b); a = t; } return a; } Write the epilogue for gcd(). lw $s0, 16($sp) lw $fp, 20($sp) lw $ra, 24($sp) addiu $sp, $sp, 28 jr $ra nop

Calling Conventions int gcd(int x, int y) { int t, a = x, b = y; while(b != 0) { t = b; b = mod(a, b); a = t; } return a; } Write the function call for mod().

Calling Conventions int gcd(int x, int y) { int t, a = x, b = y; while(b != 0) { t = b; b = mod(a, b); a = t; } return a; } Write the function call for mod(). addiu $a0, $t0, 0 addiu $a1, $t1, 0 jal MOD nop

Virtual Memory Consider a byte-addressable virtual memory system with 32-bit virtual addresses, 32-bit physical addresses, and 1 KB pages. Can we run a program that requires 16 GB of memory?

Virtual Memory Consider a byte-addressable virtual memory system with 32-bit virtual addresses, 32-bit physical addresses, and 1 KB pages. Can we run a program that requires 16 GB of memory? No: The amount of virtual memory is 2^32 bytes = 4 GB. Since only 4 GB are addressable, we cannot run a program that needs to address 16 GB.

Virtual Memory Consider a byte-addressable virtual memory system with 32-bit virtual addresses, 32-bit physical addresses, and 1 KB pages. If each entry in the single-level page table is 4 bytes long, how much space does the page-table occupy in memory?

Virtual Memory Consider a byte-addressable virtual memory system with 32-bit virtual addresses, 32-bit physical addresses, and 1 KB pages. If each entry in the single-level page table is 4 bytes long, how much space does the page-table occupy in memory? The page size is 1 KB = 2^10 bytes, so the page-offset is 10 bits. The VPN field is 32 – 10 = 22 bits long. The page table thus has 2^22 entries. Thus, the table takes up 4 * (2^22) bytes = 16 MB of memory.

Virtual Memory Consider a byte-addressable virtual memory system with 32-bit virtual addresses, 32-bit physical addresses, and 1 KB pages. If each entry in the single-level page table is 4 bytes long, how much total physical memory does a 32 MB process occupy?

Virtual Memory Consider a byte-addressable virtual memory system with 32-bit virtual addresses, 32-bit physical addresses, and 1 KB pages. If each entry in the single-level page table is 4 bytes long, how much total physical memory does a 32 MB process occupy? 16 MB page table + 32 MB process = 48 MB total

Multicore Performance Consider a program with 3 sequential parts: The first 10% can be parallelized to any extent. The next 30% can be run on up to 10 processors. The last 60% can’t be parallelized at all. The program takes 70 seconds on a single processor. How long will it take on 2 processors? On n processors, as n goes to infinity?

Multicore Performance Consider a program with 3 sequential parts: The first 10% can be parallelized to any extent. The next 30% can be run on up to 10 processors. The last 60% can’t be parallelized at all. The program takes 70 seconds on a single processor. How long will it take on 2 processors? On n processors, as n goes to infinity? (70*.1)/2 + (70*.3)/2 + (70*.6) s = s = 56 s

Multicore Performance Consider a program with 3 sequential parts: The first 10% can be parallelized to any extent. The next 30% can be run on up to 10 processors. The last 60% can’t be parallelized at all. The program takes 70 seconds on a single processor. How long will it take on 2 processors? On n processors, as n goes to infinity? (70*.1)/2 + (70*.3)/2 + (70*.6) s = s = 56 s lim n→∞ (70*.1)/n + (70*.3)/10 + (70*.6) s = s = 44.1 s

Hazards, Branches, & Cycle charts Is the branch taken? Where are the data hazards?

Hazards, Branches, & Cycle charts Is the branch taken? Where are the data hazards? Yes

Hazards, Branches, & Cycle charts Fill in the chart. Assume 1 delay slot, predict not-taken, no bypasses, and branches resolved in EXE.

Hazards, Branches, & Cycle charts Fill in the chart. Assume 1 delay slot, predict not-taken, no bypasses, and branches resolved in EXE.

Hazards, Branches, & Cycle charts Fill in the chart. Assume 1 delay slot, predict not-taken, fully bypassed, and branches resolved in EXE.

Hazards, Branches, & Cycle charts Fill in the chart. Assume 1 delay slot, predict not-taken, fully bypassed, and branches resolved in EXE.

Cache Consider a 32-bit machine with 1024 different 16-byte direct- mapped cache lines. How many tag bits, index bits, and offset bits would you expect?

Cache Consider a 32-bit machine with 1024 different 16-byte direct- mapped cache lines. How many tag bits, index bits, and offset bits would you expect? Offset: 16 bytes = 2^4 bytes, so 4 bits Index: 1024 lines = 2^10 lines, so 10 bits Tag: 32 – 4 – 10 = 18, so 18 bits

Cache Consider a 32-bit machine with 1024 different 16-byte direct- mapped cache lines. For each of the following memory accesses, specify the tag, index, and whether it would be a miss or hit.

Cache Consider a 32-bit machine with 1024 different 16-byte direct- mapped cache lines. For each of the following memory accesses, specify the tag, index, and whether it would be a miss or hit.