Chris Riesbeck, Fall Introduction to Computer Systems

Similar documents
Introduction to Computer Systems

Introduction to Computer Systems

Introduction to Computer Systems

A software view. Computer Systems. The Compilation system. How it works. 1. Preprocesser. 1. Preprocessor (cpp)

Bilgisayar Sistemlerine Genel Bakış

ENCE Computer Organization and Architecture. Chapter 1. Software Perspective

Computer Organization - Overview

CSCI2467: Systems Programming Concepts

Great Reality #2: You ve Got to Know Assembly Does not generate random values Arithmetic operations have important mathematical properties

Computer Systems Organization

Introduction to Computer Systems

Introduction to Computer Systems

Introduction to Computer Systems

Introduction Presentation A

Chapter 1 A Tour of Computer Systems

A Tour of Computer Systems

Course Overview CSCE 312. Instructor: Daniel A. Jiménez. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

Introduction to Computer Systems

Welcome To The New Foundations of Computer Systems (Fall 2017)

Introduction to Computer Systems

Introduction to Computer Architecture. Meet your Colleagues. Course Theme CISC Michela Taufer September 4, 2008

Course Information and Introduction

Overview of the ECE Computer Software Curriculum. David O Hallaron Associate Professor of ECE and CS Carnegie Mellon University

The Memory Hierarchy 10/25/16

What s next. Computer Systems A Programmer s Perspective

LC-3 Assembly Language

CS 3330 Introduction 1

High Performance Computing Lecture 1. Matthew Jacob Indian Institute of Science

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

18-447: Computer Architecture Lecture 16: Virtual Memory

198:231 Intro to Computer Organization. 198:231 Introduction to Computer Organization Lecture 14

Programming 1. Lecture 1 COP 3014 Fall August 28, 2017

CS 241 Data Organization. August 21, 2018

COS 318: Operating Systems

COMP 321: Introduction to Computer Systems

Memory Management! How the hardware and OS give application pgms:" The illusion of a large contiguous address space" Protection against each other"

Lecture 1: Course Overview

Memory Management! Goals of this Lecture!

Memory Management. Kevin Webb Swarthmore College February 27, 2018

Processes and Virtual Memory Concepts

Advanced Operating Systems (CS 202)

CS 3330 Introduction. Daniel and Charles. CS 3330 Computer Architecture 1

CS 110 Computer Architecture. Lecture 2: Introduction to C, Part I. Instructor: Sören Schwertfeger.

Memory Management. Goals of this Lecture. Motivation for Memory Hierarchy

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

CS 110 Computer Architecture. Lecture 2: Introduction to C, Part I. Instructor: Sören Schwertfeger.

CSC 2405: Computer Systems II

M2 Instruction Set Architecture

Course Overview. CSCI 224 / ECE 317: Computer Architecture. Instructors: Prof. Jason Fritts. Slides adapted from Bryant & O Hallaron s slides

Introduction to System Programming

CSCI2467: Systems Programming Concepts

CS 61C: Great Ideas in Computer Architecture Lecture 2: Introduction to C, Part I

Course Wrap-Up CSE 351 Spring

CS 31: Intro to Systems Storage and Memory. Kevin Webb Swarthmore College March 17, 2015

CSC 369H1S. Operating Systems Spring 2007 Professor Angela Demke Brown U of T

Introduction to Computer Systems: Semester 1 Computer Architecture

CS240: Programming in C

CS 241 Data Organization using C

CSci Introduction to Operating Systems. Administrivia, Intro

Unix API Books. Linux Kernel Books. Assignments and Exams. Grading for CSC 256. Operating Systems 8/31/2018. CSC 256/456 Fall

CS Programming In C

CS307: Operating Systems

Advanced Memory Organizations

CSE 303: Concepts and Tools for Software Development

Chapter 2. OS Overview

CSC 256/456: Operating Systems. Introduction. John Criswell! University of Rochester

Draft. Chapter 1 Program Structure. 1.1 Introduction. 1.2 The 0s and the 1s. 1.3 Bits and Bytes. 1.4 Representation of Numbers in Memory

Computer Systems C S Cynthia Lee Today s materials adapted from Kevin Webb at Swarthmore College

Software Project. Lecturers: Ran Caneti, Gideon Dror Teaching assistants: Nathan Manor, Ben Riva

Compilation, Disassembly, and Profiling (in Linux)

CS241 Computer Organization Spring

378: Machine Organization and Assembly Language

Welcome to CS 241 Systems Programming at Illinois

COS 318: Operating Systems. Overview. Andy Bavier Computer Science Department Princeton University

Basic Concepts COE 205. Computer Organization and Assembly Language Dr. Aiman El-Maleh

ABSTRACTION ISN T THE ENTIRE STORY

Introduction to Computer Systems /18 243, Spring st Lecture, Aug. 25 th. The course that gives CMU its Zip!

14:332:331. Lecture 1

CS 201 The Memory Hierarchy. Gerson Robboy Portland State University

CPS104 Computer Organization Lecture 1

IT 252 Computer Organization and Architecture. Introduction. Chia-Chi Teng

Introduction to C CMSC 104 Spring 2014, Section 02, Lecture 6 Jason Tang

CSCE150A. Administrivia. Overview. Hardware. Software. Example. Program. Pseudocode. Flowchart. Control Structures. Hello World Program CSCE150A

Operating System Labs. Yuanbin Wu

Computer Science & Engineering 150A Problem Solving Using Computers

EL2310 Scientific Programming

Computer Systems A Programmer s Perspective 1 (Beta Draft)

Week 0: Intro to Computers and Programming. 1.1 Why Program? 1.2 Computer Systems: Hardware and Software. Hardware Components

Syllabus of ENPM 691: Secure Programming in C

Abstractions and Reality

CS Programming In C

Review: Performance Latency vs. Throughput. Time (seconds/program) is performance measure Instructions Clock cycles Seconds.

EE 209: Programming Structures for Electrical Engineering

Read-only memory (ROM): programmed during production Programmable ROM (PROM): can be programmed once SRAM (Static RAM)

CPS104 Computer Organization Lecture 1. CPS104: Computer Organization. Meat of the Course. Robert Wagner

Chapter 2: Operating-System Structures. Operating System Concepts Essentials 8 th Edition

COS 318: Operating Systems. Overview. Prof. Margaret Martonosi Computer Science Department Princeton University

Course Outline Computing Science Department. Faculty of Science. COMP Credits Introduction to Computer Systems (3,1,0) Fall 2015

Chapter 2: Operating-System Structures

Chapter 2: Operating-System

Transcription:

Chris Riesbeck, Fall 2011 Introduction to Computer Systems

Welcome to Intro. to Computer Systems Everything you need to know http://www.cs.northwestern.edu/academics/courses/213/ Instructor: Chris Riesbeck TA: Jaime Espinosa Communication channels: Course webpage News: cs.news cs.213 Prerequisites EECS 211 or equivalent Experience with C or C++ Useful: EECS 311 2

Course theme When things break, look under the hood! Most CS courses emphasize abstraction Abstract data types, procedural abstraction, asymptotic algorithmic analysis, OOAD, Abstraction is critical to managing complexity But the reality beneath is important too Debugging how adding 2 positives resulted in a negative Efficient implementations of new abstractions Useful outcomes Become more effective programmers Better at debugging, performance tuning, Prepare for later systems classes in CS & ECE Compilers, Operating Systems, Networks,... 3

Course perspective Most systems courses are applicationcentered Operating Systems: Implement portions of an OS Compilers: Write compiler for simple language Networking: Implement and simulate network protocols This course is skills-centered By knowing more about the underlying system, you will be a more effective programmer, able to write programs that are more reliable and efficient incorporate features that require hooks into the OS We ll bring out the hidden hacker in everyone. 4

Topics Covered Programs and data Bit arithmetic, assembly, program control Aspects of architecture and compilers Memory Memory technology, memory hierarchy, caches, disks, locality Aspects of architecture and OS. Linking & exceptional control flow Object files, dynamic linking, libraries, process control, Aspects of compilers, OS, and architecture Virtual memory Virtual memory, address translation, dynamic storage allocation Aspects of architecture and OS I/O, networking & concurrency High level & low-level I/O, net programming, threads, Aspects of networking, OS, and architecture 5

Course components Lectures Higher level concepts 10% of grade from class participation 4 Labs The heart of the course in-depth understanding 2 ~ 3 weeks 10% of grade each Most can be done with partner 4 Homework assignments 10% of grade Exams midterm & final 20% of grade each 6

Lab rationale Labs focus on new skills and concepts Data Lab: computer arithmetic, digital logic. Bomb Lab: assembly language, using a debugger, understanding the stack. Malloc Lab: data layout, space/time tradeoffs Shell Lab: processes, concurrency, process control, 7

Textbooks Required: Bryant & O Hallaron, Computer Systems: A Programmer s Perspective, PH 2003. (csapp.cs.cmu.edu) Recommended: Kernighan & Ritchie (K&R), The C Programming Language, Second Edition, PH 1988 R. Stevens and S. Rago, Advanced Programming in the Unix Environment, AW 2005 8

Policies Late policy 10% off per day Cheating What is cheating? Sharing code: either by copying, retyping, looking at, or supplying a copy of a file. What is NOT cheating? Helping others use systems or tools. Helping others with high-level design issues. Helping others debug their code. Penalty for cheating: Removal from course with failing grade. 9

Facilities TLAB (Tech F-252, on the bridge to Ford) A cluster of Linux machines (e.g., TLAB- 11.cs.northwestern.edu) You should all have TLAB accounts by now; problems? contact root ( root@eecs.northwestern.edu) Need physical access to TLAB? Contact Carol Surma (carol@rhodes.ece.northwestern.edu) 10

Let s get started 11

Hello World What happens when you run hello.c on your system? /* hello world */ #include <stdio.h> int main() { printf( hello, world\n ); } 12

Information is bits + context hello.c is source code Sequence of bits (0 or 1) Manipulated in 8-bit chunks called bytes Text files: bytes interpreted as ASCII characters Each byte has an integer value that corresponds to some character, usually ASCII but international standards becoming more common E.g., # -> 35 Binary files Bytes can be data, e.g., bits in an image Or parts of code, e.g., 35 as a machine instruction Context is important The same sequence of bytes might represent a character string or machine instruction 13

Programs translate bytes to bytes unix> unix> gcc gcc o o hello hello hello.c hello.c printf.o hello.c Source program (text) Preprocessor (cpp) hello.i Compiler (cc1) Modifi ed source program (text) hello.s Assembly program (text) Assembler (as) hello.o Relocatable object programs (binary) Linker (ld) hello Executable object program (binary) Pre-processor replaces #include <stdio.h> with contents of stdio.h in hello.i Compiler translates C to assembler source (hello.s) Assembler translates assembler to machine instructions, called object code (hello.o) Linker combines object code from precompiled object libraries, e.g., printf() 14

Hardware organization CPU PC Register fi le Bus interface I/O Devices: System connections to external world. Mouse, keyboard (input); Display, disk device (output) USB controller ALU Graphics adapter System bus Memory bus Control Processor Unit Executes instructions stored in I/O MM. PC - holds address Main bridge of machine-language memory instruction from memory I/O bus Buses: transfer fixed-sized chunks of data (WORDS) Pentium: 4B bus Main Memory: Temporary storage Expansion device. Holds slots both fora program other and the devices data such it Disk manipulates. as network adapters controller Mouse Keyboard Display Disk hello executable stored on disk 15

Running Hello Running hello unix>./hello hello, world unix> What s the shell? Another program (many available in Unix) What does it do? prints a prompt waits for you to type command line loads and runs hello program 16

Running Hello Register fi le Reading the hello command from the keyboard PC ALU System bus Memory bus Bus interface I/O bridge Main memory./hello" USB controller Graphics adapter I/O bus Disk controller Expansion slots for other devices such as network adapters Mouse Keyboard Display User types "./hello" Disk 17

Running Hello PC Register fi le ALU Shell program loads hello.exe into main memory System bus Memory bus Bus interface I/O bridge Main memory hello code USB controller Graphics adapter I/O bus Disk controller Expansion slots for other devices such as network adapters Mouse Keyboard Display Disk hello executable stored on disk 18

Running Hello PC Register fi le ALU System bus The processor executes instructions and displays hello Memory bus "hello,world\n" Bus interface I/O bridge Main memory hello code USB controller Graphics adapter I/O bus Disk controller Expansion slots for other devices such as network adapters Mouse Keyboard Display "hello,world\n" Disk hello executable stored on disk 19

Caches matter System spends a lot of time moving info. around Larger storage devices are slower than smaller ones Register file ~ 100 Bytes & Main memory ~ millions of Bytes Easier and cheaper to make processors run faster than to make main memory run faster Standard answer cache CPU chip L1 Register fi le cache (SRAM) ALU Cache bus System bus Memory bus L2 cache (SRAM) Bus interface Memory bridge Main memory (DRAM) 20

Storage devices form a hierarchy Storage at one level serves as cache at the next level L1: L0: Registers On-chip L1 cache (SRAM) CPU registers hold words retrieved from cache memory. L1 cache holds cache lines retrieved from the L2 cache. Smaller, faster, and costlier (per byte) storage devices L3: L2: Off-chip L2 cache (SRAM) Main memory (DRAM) L2 cache holds cache lines retrieved from memory. Main memory holds disk blocks retrieved from local disks. L4: Local secondary storage (local disks) Local disks hold fi les retrieved from disks on remote network servers. L5: Remote secondary storage (distributed fi le systems, Web servers) 21

Operating System OS a layer of software interposed between the application program and the hardware Application programs Operating system Processor Main memory I/O devices Software Hardware Two primary goal Protect resources from misuse by applications Provide simple and uniform mechanisms for manipulating low-level hardware devices 22

OS Abstractions Files abstractions of I/O devices Virtual Memory abstraction for main memory and I/O devices Processes abstractions for processor, main memory, and I/O devices Processes Virtual memory Files Processor Main memory I/O devices 23

Processes Process OS s abstraction of a running program OS provides the illusion that a process is the only one there Context switch Saving context of one process, restoring that of another one Distorted notion of time Time shell process hello process Application code OS code Application code OS code Application code Context switch Context switch 24

Virtual Memory Illusion that each process has exclusive use of a large main memory Example Virtual address space for Linux 0xffffffff 0xc0000000 0x40000000 Kernel virtual memory User stack (created at runtime) Memory mapped region for shared libraries Memory invisible to user code printf() function Run-time heap (created at runtime by malloc) 0x08048000 EECS 213 Introduction to Computer 0 Systems Read/write data Read-only code and data Unused Loaded from the hello executable fi le 25

Networking Talking to other systems Network is treated as another I/O device Many system-level issues arise in presence of network Coping with unreliable media Cross platform compatibility Complex performance issues Expansion slots I/O bus USB controller Graphics adapter Disk controller Network adapter Mouse Keyboard Display Disk Network 26

Conclusions A computer system is more than just hardware A collection of intertwined hardware and software that must cooperate to achieve the end goal running applications The rest of our course will expand on this 27