The Hardware/Software Interface CSE 351 Spring 2016



Similar documents
CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues. Linda Shapiro Spring 2016

The Hardware/So7ware Interface CSE351 Spring 2010 (Inaugural Edi5on) 1 st Lecture, 29 March

Introduction. Compiler Design CSE 504. Overview. Programming problems are easier to solve in high-level languages

Language Processing Systems

CS 51 Intro to CS. Art Lee. September 2, 2014

CS 40 Computing for the Web

Lecture 27 C and Assembly

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z)

C# and Other Languages

The programming language C. sws1 1

CS 43: Computer Networks Course Introduction. Grab a clicker and please sit towards the front, next to other students!

How to make the computer understand? Lecture 15: Putting it all together. Example (Output assembly code) Example (input program) Anatomy of a Computer

Department of Accounting ACC Fundamentals of Financial Accounting Syllabus

Lecture 1: Course Introduction"

EE361: Digital Computer Organization Course Syllabus

CS 378: Computer Game Technology

Canisius College Computer Science Department Computer Programming for Science CSC107 & CSC107L Fall 2014

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

NORTHWESTERN UNIVERSITY Department of Statistics. Fall 2012 Statistics 210 Professor Savage INTRODUCTORY STATISTICS FOR THE SOCIAL SCIENCES

CS 261 C and Assembly Language Programming. Course Syllabus

South Plains College: General Course Syllabus

CS 301 Course Information

Syllabus for CS 134 Java Programming

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

Introducción. Diseño de sistemas digitales.1

Computer Science Theory. From the course description:

General Psychology. Fall 2015

Operating Systems Introduction

STAT 1403 College Algebra Dr. Myron Rigsby Fall 2013 Section 0V2 crn 457 MWF 9:00 am

ECE 3803: Microprocessor System Design D Term 2011 Course Syllabus Department of Electrical and Computer Engineering Worcester Polytechnic Institute

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

Corporate and Brand Identity on the Web: VIC5315 University of Florida Summer 2013

Gildart Haase School of Computer Sciences and Engineering

CSC 2405: Computer Systems II

ò Paper reading assigned for next Thursday ò Lab 2 due next Friday ò What is cooperative multitasking? ò What is preemptive multitasking?

Lab 4.4 Secret Messages: Indexing, Arrays, and Iteration

Syllabus COP2253: Introduction to Programming in Java

How to design and implement firmware for embedded systems

Introduction to Information Technology ITP 101x (4 Units)

Sample Syllabus (C++) CSCI 1301 Introduction to Programming Principles

ITS1100: Train the Trainer

REPUTATION MANAGEMENT SURVIVAL GUIDE. A BEGINNER S GUIDE for managing your online reputation to promote your local business.

n Introduction n Art of programming language design n Programming language spectrum n Why study programming languages? n Overview of compilation

COS 217: Introduction to Programming Systems

CSS 341 : Fundamentals of Programming Theory and Applications Course Syllabus-Autumn 2012

Programming Languages

CS 1361-D10: Computer Science I

MKT2413: Marketing Research Semester 2, 2013/2014

BUDT 758B-0501: Big Data Analytics (Fall 2015) Decisions, Operations & Information Technologies Robert H. Smith School of Business

Introduction to Database Systems CS4320. Instructor: Christoph Koch CS

Contents. 1 Introduction. CS 15 Collaboration Policy Fall Introduction Motivation Enforcement... 2

How To Write Portable Programs In C

Theories of Personality Psyc , Fall 2014

STAT 301 (Traditional and Online) SYLLABUS for Spring 2012

ADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

CMSC Fundamentals of Computer Programming II (C++)

CSE 6329: Special Topics in Advanced Software Engineering. Office. Class. Class Meetings in GS 109. Office hours in NH 306, after class

Overview and History of Operating Systems

CS 3530 Operating Systems. L02 OS Intro Part 1 Dr. Ken Hoganson

Assessment for Master s Degree Program Fall Spring 2011 Computer Science Dept. Texas A&M University - Commerce

Analytical Chemistry Lecture - Syllabus (CHEM 3310) The University of Toledo Fall 2012

02-201: Programming for Scientists

New York University Stern School of Business Undergraduate College

Introduction to Computer Engineering EECS 203

1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders

Introduction to Programming System Design. CSCI 455x (4 Units)

Department of Geography University of Idaho. GEOG 390: Geographic Visualization January to May 2010 COURSE OUTLINE. (subject to change)

Ch. 10 Software Development. (Computer Programming)

Operating System Overview. Otto J. Anshus

Introduction to Psychology Psych 100 Online Syllabus Fall 2014

CMSC 152: Introduction to Computer Science II

INSTRUCTION AT FSU THE FLORIDA STATE UNIVERSITY OFFICE OF DISTANCE LEARNING. A Guide to Teaching and Learning Practices

CS 253: Intro to Systems Programming

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

Napa Valley College Fall 2015 Math : College Algebra (Prerequisite: Math 94/Intermediate Alg.)

Soft processors for microcontroller programming education

Course Content Concepts

CSE 307: Principles of Programming Languages

CS 106 Introduction to Computer Science I

Embedded System Design. Disclaimer

A Python Tour: Just a Brief Introduction CS 303e: Elements of Computers and Programming

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

IT 342 Operating Systems Fundamentals Fall 2014 Syllabus

Letter from the Editor-in-Chief: What Makes an Excellent Professor?

AC : A PROCESSOR DESIGN PROJECT FOR A FIRST COURSE IN COMPUTER ORGANIZATION

SYLLABUS: EE-1301: Modern Electronic Technology

NEW YORK CITY COLLEGE OF TECHNOLOGY/CUNY Computer Systems Technology Department. COURSE: CST2403 C++ Programming Part 1 ( 4 hours, 3 credits )

CSCI 4250/6250 Fall 2015 Computer and Network Security. Instructor: Prof. Roberto Perdisci

GEOG 5200S Elements of Cartography : Serving the Community Through Cartography Spring 2015

AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping

Eastern Washington University Department of Computer Science. Questionnaire for Prospective Masters in Computer Science Students

Administrative Issues

Programming Languages

3 SOFTWARE AND PROGRAMMING LANGUAGES

Transcription:

The Hardware/Software Interface CSE 351 Instructor: Brandon Holt Teaching Assistants: Kevin Bi, Anton Goncharenko, Sarang Joshi, Xi Liu, Anthony McIntosh, Alfian Rizqi, Yufang Sun, Shan Yang http://xkcd.com/676/

Welcome! 10 weeks to see the key abstractions under the hood to describe what really happens when a program runs How is it that everything is 1s and 0s? Where does all the data get stored and how do you find it? How can more than one program run at once? What happens to a Java or C program before the hardware can execute it? What is The Stack and The Heap? And much, much, much more An introduction that will: Profoundly change/augment your view of computers and programs Connect your source code down to the hardware Leave you impressed that computers ever work. 2

Who: Course Staff Brandon Holt: 5 th year PhD student Excited to teach what was my favorite class in undergrad. I like: compilers, mountains, and sandwiches (esp. w/ avocado). First time teaching an entire class, so help me out! TAs: 8 (!) Alfian, Anton, Anthony, Kevin, Sarang, Shan, Xi, Yufang all have taken the course and most have TA d 351 in the past. Office hours will be figured out ASAP Get to know us! We are here to help you succeed And to make the course better with your help! 3

Acknowledgments Many thanks to the people whose course content we are liberally reusing with at most minor changes CMU: Randy Bryant, David O Halloran, Gregory Kesden, Markus Püschel Harvard: Matt Welsh (now at Google-Seattle) UW: Gaetano Borriello, Luis Ceze, Peter Hornyack, Hal Perkins, Ben Wood, John Zahorjan, Katelin Bailey, Ruth Anderson, Dan Grossman Not listed: dozens of TAs 4

Who are you? ~116(!) registered CSE majors, EE majors, and more! Most of you will find almost everything in the course brand new Please get to know each other, and help each other out See me if you are interested in taking the class but are not yet registered. 5

Staying In Touch Course web page: http://cs.uw.edu/351 Schedule, policies, labs, homeworks, and everything else Catalyst discussion board Keep in touch outside of class help each other Staff will monitor and contribute Course mailing list cse351a_sp16@u.washington.edu Low traffic mostly announcements; your @uw.edu is subscribed Office hours, appointments, drop-ins Spread throughout the week Staff e-mail (Brandon + TAs): cse351-staff@cs.uw.edu For things that are not appropriate for the discussion board Anonymous feedback Comments about anything related to the course where you would feel better not attaching your name, linked from website, goes directly to Brandon. 6

Course Components Lectures (28) Introduce the concepts; supplemented by textbook Sections (10) Applied concepts, important tools and skills for labs, clarification of lectures, exam review and preparation Written homework assignments (4) Mostly problems from textbook to solidify understanding Programming labs/assignments (5, plus lab 0 ) Provide in-depth understanding (via practice) of an aspect of system Exams (midterm + final) Test your understanding of concepts and principles Midterm Friday, April 29, in class Final time set by the university: Wednesday June 8, 2:30-4:20PM 7

Policies: Grading Exams (45%): 15% midterm, 30% final Many old exams on course website (but now 64-bit, +new instructor) Written assignments (20%): weighted according to effort We ll try to make these about the same Lab assignments (35%): weighted according to effort These will likely increase in weight as the quarter progresses Late days: 3 late days to use as you wish throughout the quarter see website Collaboration: http://www.cse.uw.edu/education/courses/cse351/16sp/policies.html http://www.cse.uw.edu/students/policies/misconduct Do not cheat!!! It s an affront to the course staff, your fellow students, and yourself. CSE courses are special and valuable keep it that way! 8

Textbooks Computer Systems: A Programmer s Perspective, 3 rd Edition Randal E. Bryant and David R. O Hallaron Prentice-Hall, 2015 http://csapp.cs.cmu.edu 3rd edition includes complete rewrite of Chapter 3 All code examples in x86-64 http://csapp.cs.cmu.edu/3e/changes3e.html This book really matters for the course! How to solve labs Practice problems typical of exam problems A good C book any will do The C Programming Language (Kernighan and Ritchie) C: A Reference Manual (Harbison and Steele) 9

Videos / Online course Gaetano Borriello and Luis Ceze made videos in 2013 covering the course content [for an online version of the course] And self-check quiz questions These are a great resource encourage you to watch them Generally optional unless class is cancelled or something Occasionally may require before class so you don t get lost in an example But some content has changed Now all 64-bit so some videos may have extra information no longer relevant. This means we may get to new things that class didn t get to. If in doubt, go with what we talked about in this class. 10

Other details Consider taking CSE 391 Unix Tools, 1 credit, useful skills Available to all CSE majors and everyone registered in CSE351 Office hours will be held this week, check web page for times 11

Concise To-Do List Review syllabus, course goals, collaboration policy, etc.: http://cs.uw.edu/351 Make sure you are receiving announcement emails Beginning-of-course survey, due Friday Lab 0, due Monday, January 11 at 5pm Make sure you get our virtual machine set up and are able to do work Basic exercises to start getting familiar with C Credit/no-credit Get this done as quickly as possible Section Thursday Please install the virtual machine BEFORE coming to section BRING your computer with you to section Includes activities to help you get started with Lab 0 12

Anything I forgot about course mechanics before we discuss, you know, hardware and software? 13

The Hardware/Software Interface What do we mean by hardware? software? What is an interface? Why do we need a hardware/software interface? Why do we need to understand both sides of this interface? 1000001101111100001001000001110000000000 0111010000011000 10001011010001000010010000010100 10001011010001100010010100010100 100011010000010000000010 1000100111000010 110000011111101000011111 11110111011111000010010000011100 10001001010001000010010000011000 1000001101111100001001000001110000000000 0111010000011000 10001011010001000010010000010100 10001011010001100010010100010100 100011010000010000000010 1000100111000010 110000011111101000011111 11110111011111000010010000011100 10001001010001000010010000011000

C/Java, assembly, and machine code if (x!= 0) y = (y+z)/x; ê cmpl $0, -4(%ebp) je.l2 movl -12(%ebp), %eax movl -8(%ebp), %edx leal (%edx, %eax), %eax movl %eax, %edx sarl $31, %edx idivl -4(%ebp) movl %eax, -8(%ebp).L2: ê 1000001101111100001001000001110000000000 0111010000011000 10001011010001000010010000010100 10001011010001100010010100010100 100011010000010000000010 1000100111000010 110000011111101000011111 11110111011111000010010000011100 10001001010001000010010000011000 High Level Language (e.g. C, Java) Assembly Language Machine Code 15

C/Java, assembly, and machine code if (x!= 0) y = (y+z)/x; ê Compiler ê cmpl $0, -4(%ebp) je.l2 movl -12(%ebp), %eax movl -8(%ebp), %edx leal (%edx, %eax), %eax movl %eax, %edx sarl $31, %edx idivl -4(%ebp) movl %eax, -8(%ebp).L2: ê Assembler ê 1000001101111100001001000001110000000000 0111010000011000 10001011010001000010010000010100 10001011010001100010010100010100 100011010000010000000010 1000100111000010 110000011111101000011111 11110111011111000010010000011100 10001001010001000010010000011000 High Level Language (e.g. C, Java) Assembly Language Machine Code 16

C/Java, assembly, and machine code 1000001101111100001001000001110000000000 0111010000011000 10001011010001000010010000010100 10001011010001100010010100010100 100011010000010000000010 1000100111000010 110000011111101000011111 11110111011111000010010000011100 10001001010001000010010000011000 if (x!= 0) y = (y+z)/x; ê cmpl $0, -4(%ebp) je.l2 movl -12(%ebp), %eax movl -8(%ebp), %edx leal (%edx, %eax), %eax movl %eax, %edx sarl $31, %edx idivl -4(%ebp) movl %eax, -8(%ebp).L2: ê l The three program fragments are equivalent l You'd rather write C! (more human-friendly) l Hardware likes bit strings! l l Everything is voltages The machine instructions are actually much shorter than the number of bits we would need to represent the characters in the assembly language 17

HW/SW Interface: Historical Perspective Hardware started out quite primitive http://www.acronis.com/en-us/blog/posts/backups-and-business-continuity-cavemen-were-something 18

HW/SW Interface: Historical Perspective Hardware started out quite primitive Jean Jennings (left), Marlyn Wescoff (center), and Ruth Lichterman program ENIAC at the University of Pennsylvania, circa 1946.Photo: Corbis http://fortune.com/2014/09/18/walter-isaacson-the-women-of-eniac/ http://hightechhistory.com/2011/10/24/the-late-dennis-macalistair-ritchie innovator-of-the-%e2%80%9cc%e2%80%9d-programming-language-and- 19

HW/SW Interface: Historical Perspective Hardware started out quite primitive Programmed with very basic instructions. E.g. a single instruction for adding two integers Software was also very basic Closely reflected the actual hardware it was running on Specify each step manually Architecture Specification (Interface) Hardware 20

HW/SW Interface: Assemblers Life was made a lot better by assemblers 1 assembly instruction = 1 machine instruction, but... different syntax: assembly instructions are character strings, not bit strings, a lot easier to read/write by humans can use symbolic names Assembler specification User program in assembly language Assembler Hardware 21

HW/SW Interface: Higher-Level Languages Higher level of abstraction: 1 line of a high-level language is compiled into many (sometimes very many) lines of assembly language C language specification User progra m in C C compiler Assembler Hardware 22

HW/SW Interface: Code / Compile / Run Times Code Time Compile Time Run Time User progra m in C C compiler Assembler Hardware.c file.exe file Note: The compiler and assembler are just programs, developed using this same process. 23

The Big Theme: Abstractions and Interfaces Computing is about abstractions (but we can t forget reality) What are the abstractions that we use? What do you need to know about them? When do they break down and you have to peek under the hood? What bugs can they cause and how do you find them? How does the hardware (0s and 1s, processor executing instructions) relate to the software (C/Java programs)? Become a better programmer and begin to understand the important concepts that have evolved in building ever more complex computer systems 24

Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp %rbp 0111010000011000 100011010000010000000010 1000100111000010 110000011111101000011111 Java: Car c = new Car(); c.setmiles(100); c.setgals(17); float mpg = c.getmpg(); OS: Memory & data Integers & floats Machine code & C x86 assembly Procedures & stacks Arrays & structs Memory & caches Processes Virtual memory Memory allocation Java vs. C Computer system: 25

Little Theme 1: Representation All digital systems represent everything as 0s and 1s The 0 and 1 are really two different voltage ranges in the wires Or magnetic positions on a disc, or hole depths on a DVD, or even DNA Everything includes: Numbers integers and floating point Characters the building blocks of strings Instructions the directives to the CPU that make up a program Pointers addresses of data objects stored away in memory These encodings are stored throughout a computer system In registers, caches, memories, disks, etc. They all need addresses A way to find them Find a new place to put a new item Reclaim the place in memory when data no longer needed 26

Little Theme 2: Translation There is a big gap between how we think about programs and data and the 0s and 1s of computers Need languages to describe what we mean These languages need to be translated one level at a time We know Java as a programming language Have to work our way down to the 0s and 1s of computers Try not to lose anything in translation! We ll encounter Java byte-codes, C language, assembly language, and machine code (for the X86 family of CPU architectures) Not in that order, but will all connect by the last lecture!!! 27

Little Theme 3: Control Flow How do computers orchestrate everything they are doing? Within one program: How do we implement if/else, loops, switches? What do we have to keep track of when we call a procedure, and then another, and then another, and so on? How do we know what to do upon return? Across programs and operating systems: Multiple user programs Operating system has to orchestrate them all Each gets a share of computing cycles They may need to share system resources (memory, I/O, disks) Yielding and taking control of the processor Voluntary or by force? 28

Writing Assembly Code??? In 2016??? Chances are, you ll never write a program in assembly Compilers are much better and more patient than you are But: understanding assembly is the key to the machine-level execution model Behavior of programs in presence of bugs High-level language model breaks down Tuning program performance Understand optimizations done/not done by the compiler Understanding sources of program inefficiency Implementing system software Operating systems must manage process state Fighting malicious software Using special units (timers, I/O co-processors, etc.) inside processor! 29

Course Outcomes Understanding of some of the abstractions that exist between programs and the hardware they run on, why they exist, and how they build upon each other Knowledge of some of the details of underlying implementations Less important later, but cannot get it without doing it and doing it requires details Become more effective programmers Understand some of the many factors that influence program performance More efficient at finding and eliminating bugs Facility with more languages that we use to describe programs and data Better understand new hardware Prepare for later classes in CSE 30

CSE351 s role in the CSE Curriculum Pre-requisites 142 and 143: Intro Programming I and II Also recommended: 391: System and Software Tools Complementary to: CSE311->CSE369->EE371 / EE271->EE371: hardware design below us arranging wires to do addition and stuff EE/CSE474 embedded systems: CSE351 invaluable but not a pre-req [EE] CSE331/332/341: high-level software design and structures Essential pre-req for: CSE401: compilers write a program to do CSE351 translations CSE333: building well-structured systems in C/C++ Courses after CSE333: OS, networks, distributed systems, graphics, 31

Course Perspective CSE351 will make you a better programmer Purpose is to show how software really works Understanding the underlying system makes you more effective Better debugging Better basis for evaluating performance How multiple activities work in concert (e.g., OS and user programs) Not just a course for hardware enthusiasts! What every CSE major needs to know (plus many more details) See many patterns that come up over and over in computing (like caching) Like other 300-level courses, stuff everybody learns and uses and forgets not knowing CSE351 presents a world-view that will empower you The intellectual tools and software tools to understand the trillions+ of 1s and 0s that are flying around when your program runs 32

HTTP://XKCD.COM/676/ 33