CS 3410: Computer System Organization and Programming
description
Transcript of CS 3410: Computer System Organization and Programming
![Page 1: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/1.jpg)
CS 3410: Computer System Organization and Programming
Hakim WeatherspoonCS 3410, Spring 2013
Computer ScienceCornell University
![Page 2: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/2.jpg)
Computer System Organization
The most amazing and likely to be most long-lived invention of the 1800’s was…
![Page 3: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/3.jpg)
Computer System Organization
The most amazing and likely to be most long-lived invention of the 1800’s was…
• (a) The steam engine?• (b) The lightning rod?• (c) The carbonated beverage?• (d) All of the above• (e) None
![Page 4: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/4.jpg)
Computer System Organization
The most amazing and likely to be most long-lived invention of the 1800’s was…
THE ELECTRIC SWITCH
![Page 5: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/5.jpg)
Basic Building Blocks: A switch
A switch is a simple device that can act as a conductor or isolator
Can be used for amazing things…
![Page 6: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/6.jpg)
• NMOS Transistor
• Connect source to drain when VG = Vsupply
• N-channel transistor
VS = 0 V
VGVG = VSupply VG = 0 V
NMOS and PMOS Transistors
PMOS Transistor
Connect source to drain when VG = 0 VP-channel transistor
VG VG = VSupply VG = 0 V
VD VD = 0V
Closed switchWhen VG = Vsupply
Closed switchWhen VG = 0 V
Vsupply
VS = Vsupply
Vsupply Vsupply
VD
VS: voltage at the sourceVD: voltage at the drainVsupply: max voltage (aka a logical 1) (ground): min voltage (aka a logical 0)
VD = Vsupply
![Page 7: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/7.jpg)
• NMOS Transistor
• Connect source to drain when gate = 1
• N-channel transistor
D
S = 0V
G G = 1 G = 0
NMOS and PMOS Transistors
PMOS Transistor
Connect source to drain when gate = 0P-channel transistor
Vsupply
D
G G = 1 G = 0
D = 0
Closed switchWhen VG = Vsupply
Closed switchWhen VG = 0 V
S = Vsupply
Vsupply Vsupply
D = 1
VS: voltage at the sourceVD: voltage at the drainVsupply: max voltage (aka a logical 1) (ground): min voltage (aka a logical 0)
![Page 8: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/8.jpg)
Inverter
In Out0 11 0
• Function: NOT• Called an inverter• Symbol:
• Useful for taking the inverse of an input
• CMOS: complementary-symmetry metal–oxide–semiconductor
in out
Truth table
in out
Vsupply (aka logic 1)
0 1
(ground is logic 0)
![Page 9: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/9.jpg)
Inverter
In Out0 11 0
• Function: NOT• Called an inverter• Symbol:
• Useful for taking the inverse of an input
• CMOS: complementary-symmetry metal–oxide–semiconductor
in out
Truth table
in out
Vsupply
1 0
Vsupply (aka logic 1)
(ground is logic 0)
![Page 10: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/10.jpg)
NAND Gate
A B out0 0 11 0 10 1 11 1 0
• Function: NAND• Symbol:
b
aout
A
out
Vsupply
B
BA
Vsupply
1
1
1 1
0
![Page 11: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/11.jpg)
NOR Gate
A B out0 0 11 0 00 1 01 1 0
• Function: NOR• Symbol:
b
aout
A
out
Vsupply
B
BA
0
0
0 0
1
![Page 12: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/12.jpg)
Building Functions
NOT:
AND:
OR:
NAND and NOR are universal• Can implement any function with NAND or just NOR gates• useful for manufacturing
b
a
b
a
![Page 13: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/13.jpg)
Then and Now
The first transistor• on a workbench at
AT&T Bell Labs in 1947• Bardeen, Brattain, and Shockley
• An Intel Westmere– 1.17 billion transistors– 240 square millimeters– 32 nanometer: transistor gate width– Six processing cores– Release date: January 2010
http://www.theregister.co.uk/2010/02/03/intel_westmere_ep_preview/
![Page 14: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/14.jpg)
Then and Now
The first transistor• on a workbench at
AT&T Bell Labs in 1947• Bardeen, Brattain, and Shockley
• An Intel Ivy Bridge– 1.4 billion transistors– 160 square millimeters– 22 nanometer: transistor gate width– Up to eight processing cores– Release date: April 2012
http://forwardthinking.pcmag.com/none/296972-intel-releases-ivy-bridge-first-processor-with-tri-gate-transistor
![Page 15: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/15.jpg)
Then and Now
The first transistor• on a workbench at
AT&T Bell Labs in 1947• Bardeen, Brattain, and Shockley
• Samsung Galaxy Note II– Eynos 4412 System on a Chip (SoC)– ARM Cortex-A9 processing core– 32 nanometer: transistor gate width– Four processing cores– Release date: November 2012
http://www.anandtech.com/show/6386/samsung-galaxy-note-2-review-t-mobile-/3
![Page 16: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/16.jpg)
Moore's Law
The number of transistors integrated on a single die will double every 24 months...
– Gordon Moore, Intel co-founder, 1965
Amazingly Visionary1971 – 2300 transistors – 1MHz – 40041990 – 1M transistors – 50MHz – i4862001 – 42M transistors – 2GHz – Xeon2004 – 55M transistors – 3GHz – P42007 – 290M transistors – 3GHz – Core 2 Duo2009 – 731M transistors – 2GHz – Nehalem2012 – 1400M transistors – 2-3GHz – Ivy Bridge
![Page 17: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/17.jpg)
Course Objective
Bridge the gap between hardware and software• How a processor works• How a computer is organized
Establish a foundation for building higher-level applications• How to understand program performance• How to understand where the world is going
![Page 18: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/18.jpg)
Announcements: How class organizedInstructor: Hakim Weatherspoon ([email protected])
Lecture:• Tu/Th 1:25-2:40• Olin 155
Lab Sections:• Carpenter 104 (Blue Room)• Carpenter 235 (Red Room)
Required Textbooks
SuggestedTextbook
![Page 19: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/19.jpg)
Who am I?
Prof. Hakim Weatherspoon • (Hakim means Doctor, wise, or prof. in Arabic)• Background in Education
– Undergraduate University of Washington Played Varsity Football
» Some teammates collectively make $100’s of millions» I teach!!!
– Graduate University of California, Berkeley Some class mates collectively make $100’s of millions I teach!!!
• Background in Operating Systems– Peer-to-Peer Storage
Antiquity project - Secure wide-area distributed system OceanStore project – Store your data for 1000 years
– Network overlays Bamboo and Tapestry – Find your data around globe
– Tiny OS Early adopter in 1999, but ultimately chose P2P direction
![Page 20: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/20.jpg)
Who am I?
Cloud computing/storage• Optimizing a global network of data centers• Cornell Ntional λ-Rail Rings testbed• Software Defined Network Adapter• Energy: KyotoFS/SMFS
Antiquity: built a global-scale storage system
![Page 21: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/21.jpg)
Course [email protected]
Lecture/Homwork TA’s• Detian Shi ([email protected])• Paul Upchurch ([email protected]) (lead)• Paul Heran Yang ([email protected])
Lab TAs• Efe Gencer ([email protected])• Erluo Li ([email protected])• Han Wang ([email protected]) (lead)
Lab Undergraduate consultants• Roman Averbukh ([email protected])• Favian Contreras ([email protected])• Jisun Jung ([email protected])• Emma Kilfoyle ([email protected])• Joseph Mongeluzzi ([email protected])• Sweet Song ([email protected])• Peter Tseng ([email protected])• Victoria Wu ([email protected])• Jason Zhao ([email protected])
Administrative Assistant: • Molly Trufant ([email protected])
![Page 22: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/22.jpg)
Pre-requisites and schedulingCS 2110 is required (Object-Oriented Programming and Data Structures)
• Must have satisfactorily completed CS 2110• Cannot take CS 2110 concurrently with CS 3410
CS 3420 (ECE 3140) (Embedded Systems)• Take either CS 3410 or CS 3420
– both satisfy CS and ECE requirements• However, Need ENGRD 2300 to take CS 3420
CS 3110 (Data Structures and Functional Programming)• Not advised to take CS 3110 and 3410 together
![Page 23: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/23.jpg)
Pre-requisites and schedulingCS 2043 (UNIX Tools and Scripting)
• 2-credit course will greatly help with CS 3410. • Meets Mon, Wed, Fri at 11:15am-12:05pm in Phillips (PHL) 203• Class started yesterday and ends March 1st
CS 2022 (Introduction to C)• 1-credit course will greatly help with CS 3410• Unfortunately, offered in the fall, not spring• Instead, we will offer a primer to C next Monday, January 28th, 6-
8pm. Location TBD.
![Page 24: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/24.jpg)
Schedule (subject to change)Week Date (Tue) Lecture# Lecture Topic HW Prelim Lab Topic Lab/Proj
1 22-Jan 1Intro Logisim Lab 0: Adder/Logisim intro Handout 2Logic & Gates
2 29-Jan 3Numbers & Arithmetic HW1: Logic, Gates, Numbers, & Arithmetic
ALU lab 1: ALU Handout (design doc due one-week, lab1 due two-weeks)
4State & FSMs 3 5-Feb 5Memory FSM Lab 2: (IN-CLASS) FSM Handout
6Simple CPU 4 12-Feb 7CPU Performance & Pipelines HW2: FSMs, Memory, CPU,
Performance, and pipelined MIPSMIPS Proj 1: MIPS 1 Handout
8Pipelined MIPS 5 19-Feb 9Pipeline Hazards Fast Adder? Proj 1: Design Doc Due
10Control Hazards & ISA Variations
6 26-Feb 11RISC & CISC Prelim 1 MIPS Help Lab? 12Calling Conventions
7 5-Mar 13Calling Conventions HW3: Calling Conventions, RISC, CISC, Linkers
MIPS 2 Proj 2: MIPS 2 Handout
14Calling Conventions 8 12-Mar 15Linkers C for Java
ProgrammersProj 2: Design Doc Due
16Linkers & Caches 1 MIPS 2 Help 19-Mar Spring Break Spring Break
9 26-Mar 17Caches 1 Intro to UNIX/Linux 18Caches 2 Prelim 2 ssh, gcc, How to tunnel
10 2-Apr 19Virtual Memory 1 Stack Smashing Lab 3: Buffer Overflows handout 20Virtual Memory 2
11 9-Apr 21Virtual Memory 3 & Traps HW4: Virtual memory, Caches, Caches Proj 3: Caches Handout 22Multicore Architectures Traps, Multicore, Exceptions???
12 16-Apr 23Synchronization Caches Help? 24Synchronization 2
13 23-Apr 25Prelim 3 Review Virtual Memory Lab 4: (IN-CLASS) Virtual Memory 26Synchronization 2 Prelim 3
14 30-Apr 27I/O Synchronization Proj 4: Multicore/NW Handout 28Future Directions Proj 4 Help Lab? 7-May Proj 4: Design Doc Due 15-May 5/15/2012
4:30pm Proj 4 Due
![Page 25: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/25.jpg)
Grading
Lab (45-50%)• 5-6 Individual Labs (15-17.5%)
– 2 out-of-class labs (10%)– 3-4 in-class labs (5-7.5%)
• 4 Group Projects (30%)• Quizzes in lab (2.5%)
Lecture (45-50%)• 3 Prelims (32.5 - 37.5%)
– Tue Feb 26th, Thur Mar 28th, and Thur Apr 25th • Homework (10%)• Quizzes in lecture (2.5%)
Participation/Discretionary (5%)
![Page 26: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/26.jpg)
Grading
Regrade policy• Submit written request to lead TA,
and lead TA will pick a different grader • Submit another written request,
lead TA will regrade directly • Submit yet another written request for professor to
regrade.
Late Policy• Each person has a total of four “slip days”• Max of two slip days for any individual assignment• For projects, slip days are deducted from all partners • 25% deducted per day late after slip days are exhausted
![Page 27: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/27.jpg)
Active Learning
iClicker: Bring to every Lecture
Put all devices into Airplane Mode
![Page 28: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/28.jpg)
Fig. 1 Histogram of 270 physic student scores for the two sections:Experiment w/ quizzes and active learning. Control without.
L Deslauriers et al. Science 2011;332:862-864
Published by AAAS
Active Learning
![Page 29: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/29.jpg)
Administrivia
http://www.cs.cornell.edu/courses/cs3410/2013sp• Office Hours / Consulting Hours• Lecture slides & schedule• Logisim• CSUG lab access (esp. second half of course)
Lab Sections (start today)• Labs are separate than lecture and homework
• Bring laptop to Labs (optional)
![Page 30: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/30.jpg)
Communication
Email• [email protected]• The email alias goes to me and the TAs, not to whole class
Assignments• CMS: http://cms.csuglab.cornell.edu
Newsgroup• http://www.piazza.com/cornell/spring2012/cs3410• For students
iClicker• http://atcsupport.cit.cornell.edu/pollsrvc/
![Page 31: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/31.jpg)
Lab Sections & Projects
Lab Sections start this week• Intro to logisim and building an adder
Labs Assignments• Individual• One week to finish (usually Monday to Monday)
Projects • two-person teams• Find partner in same section
![Page 32: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/32.jpg)
Academic Integrity
All submitted work must be your own• OK to study together, but do not share soln’s• Cite your sources
Project groups submit joint work• Same rules apply to projects at the group level• Cannot use of someone else’s soln
Closed-book exams, no calculators
• Stressed? Tempted? Lost?• Come see me before due date!
Plagiarism in any form will not be tolerated
![Page 33: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/33.jpg)
Why do CS Students Need Transistors?
![Page 34: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/34.jpg)
Why do CS Students Need Transistors?
Functionality and Performance
![Page 35: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/35.jpg)
Why do CS Students Need Transistors?
To be better Computer Scientists and Engineers• Abstraction: simplifying complexity• How is a computer system organized? How do I build it?• How do I program it? How do I change it?• How does its design/organization effect performance?
![Page 36: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/36.jpg)
Computer System Organization
![Page 37: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/37.jpg)
Computer System OrganizationComputer System = ?Input +Output +Memory +Datapath +Control
CPU
Registers
NetworkVideo
bus
Memory
bus
Disk
USB
Audio
Keyboard Mouse
Serial
![Page 38: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/38.jpg)
Compilers & Assemblers
int x = 10;x = 2 * x + 15;C
compiler
addi r5, r0, 10muli r5, r5, 2addi r5, r5, 15
MIPSassemblylanguage
001000000000010100000000000010100000000000000101001010000100000000100000101001010000000000001111
MIPSmachinelanguage
assembler
r0 = 0
r5 = r0 + 10r5 = r5 * 2r5 = r15 + 15
op = addi r0 r5 10
op = addi r5 r5 15
![Page 39: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/39.jpg)
Instruction Set Architecture
ISA• abstract interface between hardware and the
lowest level software
• user portion of the instruction set plus the operating system interfaces used by application programmers
![Page 40: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/40.jpg)
Basic Computer System
A processor executes instructions• Processor has some internal state in storage
elements (registers)A memory holds instructions and data
• von Neumann architecture: combined inst and data
A bus connects the two
regsbus
processor memory
0101000010010100
…addr, data,
r/w
![Page 41: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/41.jpg)
How to Design a Simple Processor
memory
inst
32
pc
200
new pccalculation
register file
control
5 5 5
alu
00: addi r5, r0, 1004: muli r5, r5, 208: addi r5, r5, 15
r0
r5
10
0 10
![Page 42: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/42.jpg)
Inside the Processor
AMD Barcelona: 4 processor cores
Figure from Patterson & Hennesssy, Computer Organization and Design, 4 th Edition
![Page 43: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/43.jpg)
How to Program the Processor:MIPS R3000 ISA
Instruction Categories• Load/Store• Computational• Jump and Branch• Floating Point
– coprocessor• Memory Management
R0 - R31
PCHILO
OP
OP
OP
rs rt rd sa funct
rs rt immediate
jump target
Registers
![Page 44: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/44.jpg)
Overview
I/O systemInstr. Set Proc.
Compiler
OperatingSystem
Application
Digital DesignCircuit Design
Instruction Set Architecture
Firmware
Memory system
Datapath & Control
![Page 45: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/45.jpg)
Applications
Everything these days!• Phones, cars, televisions, games, computers,…
![Page 46: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/46.jpg)
Applications
47
Berkeley mote
NVidia GPU
Xilinx FPGA mill
ions
1997 1999 2001 2003 2005 20070
200
400
600
800
1000
1200
110295
405502
785
93 114 135 136 202 265189 200
Cell PhonesPCsTVs
Cell Phone
Cloud Computing
Cars
![Page 47: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/47.jpg)
Covered in this course
I/O systemInstr. Set Proc.
Compiler
OperatingSystem
Application
Digital DesignCircuit Design
Instruction Set Architecture
Firmware
Memory system
Datapath & Control
![Page 48: CS 3410: Computer System Organization and Programming](https://reader036.fdocuments.net/reader036/viewer/2022062521/5681694c550346895de0ea1b/html5/thumbnails/48.jpg)
Reflect
Why take this course? Basic knowledge needed for all other areas of CS:
operating systems, compilers, ... Levels are not independent
hardware design ↔ software design ↔ performance Crossing boundaries is hard but important
device drivers Good design techniques
abstraction, layering, pipelining, parallel vs. serial, ... Understand where the world is going