Welcome to CS 449: Introduc3on to System So6ware. Instructor: Wonsun Ahn

Similar documents
First of all, it is a variable, just like other variables you studied

Computer Systems: A Programmer s Perspec4ve. Have a tour of computer system at first... Chapter 1

CHAPTER 1 Introduction to Computers and Java

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

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

CS 61C: Great Ideas in Computer Architecture Introduc=on to C, Part I. We are here!

CS240: Programming in C. Lecture 2: Overview

Data Representation and Storage. Some definitions (in C)

CS 61C: Great Ideas in Computer Architecture. Lecture 3: Pointers. Bernhard Boser & Randy Katz

W1005 Intro to CS and Programming in MATLAB. Brief History of Compu?ng. Fall 2014 Instructor: Ilia Vovsha. hip://

Virtualization. Introduction. Why we interested? 11/28/15. Virtualiza5on provide an abstract environment to run applica5ons.

Agenda. Components of a Computer. Computer Memory Type Name Addr Value. Pointer Type. Pointers. CS 61C: Great Ideas in Computer Architecture

CS 61C: Great Ideas in Computer Architecture. Lecture 3: Pointers. Krste Asanović & Randy Katz

Week 3 Lecture 2. Types Constants and Variables

CSE Opera*ng System Principles

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995

Data Representation and Storage

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

CSC 1600 Memory Layout for Unix Processes"

OBJECT ORIENTED PROGRAMMING

Introduction to Computer Systems

CS 61C: Great Ideas in Computer Architecture. C Arrays, Strings, More Pointers

Introduction to Computer Systems

CS Prof J.P.Morrison

Pointers (continued), arrays and strings

EL2310 Scientific Programming

Programming. Data Structure

Agenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011

CS2303 C14 Systems Programming Concepts. Bob Kinicki

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan

Incoming Exam. CS 201 Introduction to Pointers. What is a Pointer? Pointers and Addresses. High Speed Memory (RAM) Size of Variable Types.

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

Alterna(ve Architectures

Lecture 8 Dynamic Memory Allocation

Memory Management. CS449 Fall 2017

Pointers (continued), arrays and strings

CS 61C: Great Ideas in Computer Architecture Strings and Func.ons. Anything can be represented as a number, i.e., data or instruc\ons

C Pointers. ENGG1002 Computer Programming and Applica;ons Dr. Hayden Kwok Hay So Week 2. GeGng Hold of Memory. Sta;c: When we define a variable

Outline. Lecture 1 C primer What we will cover. If-statements and blocks in Python and C. Operators in Python and C

CS 61c: Great Ideas in Computer Architecture

Work relative to other classes

CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language. Krste Asanović & Randy Katz

CS133 C Programming. Instructor: Jialiang Lu Office: Information Center 703

Agenda. CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language 8/29/17. Recap: Binary Number Conversion

How a computer runs a program. Binary Representa8on and Opera8ons on Binary Data. Opera8ng System 9/17/13. You can view binary file contents

Chris Riesbeck, Fall Introduction to Computer Systems

o Code, executable, and process o Main memory vs. virtual memory

Opera&ng Systems ECE344

Dynamic Data Structures. CSCI 112: Programming in C

Dynamic Memory Allocation and Command-line Arguments

Hacking in C. Pointers. Radboud University, Nijmegen, The Netherlands. Spring 2019

Section Notes - Week 1 (9/17)

CONTAINERIZING JOBS ON THE ACCRE CLUSTER WITH SINGULARITY

CSC231 C Tutorial Fall 2018 Introduction to C

Automa6on and API Programming with Femap and NX Nastran

PRINCIPLES OF OPERATING SYSTEMS

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

C Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Introduction to Python: Data types. HORT Lecture 8 Instructor: Kranthi Varala

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

BBM 101 Introduc/on to Programming I Fall 2014, Lecture 3. Aykut Erdem, Erkut Erdem, Fuat Akal

Opera&ng Systems: Principles and Prac&ce. Tom Anderson

CS 61C: Great Ideas in Computer Architecture Introduc)on to C, Part II

Modern Instruc?on Sets

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ.

CS Programming In C

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

Chapter 1: Why Program? Main Hardware Component Categories 8/23/2014. Main Hardware Component Categories: Why Program?

6.096 Introduction to C++ January (IAP) 2009

Reading assignment. Chapter 3.1, 3.2 Chapter 4.1, 4.3

Basic C Program: Print to stdout. Basic C Program. Basic C Program: Print to stdout. Header Files. Read argument and print. Read argument and print

C - Basics, Bitwise Operator. Zhaoguo Wang

CS 220: Introduction to Parallel Computing. Arrays. Lecture 4

CS 61C: Great Ideas in Computer Architecture C Pointers. Instructors: Vladimir Stojanovic & Nicholas Weaver

10/7/15. MediaItem tostring Method. Objec,ves. Using booleans in if statements. Review. Javadoc Guidelines

C Arrays, Strings, More Pointers Instructor: Steven Ho

Operating System: Chap2 OS Structure. National Tsing-Hua University 2016, Fall Semester

Chapter 3. Fundamental Data Types

Lecture 9: Potpourri: Call by reference vs call by value Enum / struct / union Advanced Unix

Hardware OS & OS- Application interface

Midterm CSE 131B Spring 2005

Modern Instruc?on Sets

Arrays and Memory Management

Lecture 8: Memory Management

Objec+ves. Review. Basics of Java Syntax Java fundamentals. What are quali+es of good sooware? What is Java? How do you compile a Java program?

Agenda. Old School CS61c. Agenda. New School CS61c 8/26/10. CS 61C: Great Ideas in Computer Architecture (Machine Structures)

Background. IBM sold expensive mainframes to large organiza<ons. Monitor sits between one or more OSes and HW

Lecture 8: Structs & File I/O

Lecture 1: Course Overview

Instructor: Randy H. Katz hbp://inst.eecs.berkeley.edu/~cs61c/fa13. Fall Lecture #4. Agenda

CS 61C: Great Ideas in Computer Architecture Introduction to C

Chapter 1: Introduction to Computers and Programming

Background. IBM sold expensive mainframes to large organiza<ons. Monitor sits between one or more OSes and HW

The Kernel Abstrac/on

C Introduction. Comparison w/ Java, Memory Model, and Pointers

Instructors: Randy H. Katz David A. PaHerson hhp://inst.eecs.berkeley.edu/~cs61c/fa10. Fall Lecture #1. Agenda

Two s Complement Review. Two s Complement Review. Agenda. Agenda 6/21/2011

Transcription:

Welcome to CS 449: Introduc3on to System So6ware Instructor: Wonsun Ahn

What is a System? Merriam-Webster dic3onary: A group of related parts that work together Your computer hardware is a system Comprised of dis3nct parts Motherboard, CPU, Memory Devices (network, hard drive, key board, mouse) With well-defined interfaces DDR, PCI Express, SATA, USB ISA (Instruc3on Set Architecture) Interfaces allow parts to be interchanged

Is Computer So6ware a System? Is so6ware composed of dis3nct parts? Not in the old days Applica3ons were monolithic pieces of so6ware That ran directly on top of computer hardware That included code to manage / control HW O6en wriyen in machine (assembly) language Problems with monolithic so6ware Repe33ve implementa3ons of code to control HW So6ware is 3ed to underlying HW (not portable) Cannot have two pieces of SW running on same HW

Modern So6ware is a System So6ware is divided into applica3on and system so6ware Applica3on So6ware So6ware that performs some useful task E.g. Web browser, word processor, video streamer System So6ware So6ware that is provide services that enable apps to run Opera3ng System Gate keeper to HW resources (CPUs, Memory, Devices ) Distributes HW resources among apps in a fair manner Abstracts HW into a well-defined interface for apps Compiler Translates apps from programming language to HW machine language Allows apps to be wriyen in high level languages (e.g. Java, Python )

What we will Learn Theory How different parts of the so6ware system interact with each other and the hardware system From the perspec3ve of the applica3on Its well-defined interface with the HW Its well-defined interface with the OS What role the compiler plays in transla3ng the applica3on Prac3ce (Unix) C programming language System so6ware programming

Where it Fits in What you should have taken before CS 445: Data Structures CS 447: Computer Organiza3on and Assembly Language Programming What you can take a(er CS 1550: Introduc3on to Opera3ng Systems CS 1622: Introduc3on to Compiler Design

Why Learn System So6ware? Learn how to build system so6ware System so6ware provide services for many apps Needs to be efficient Needs to be reliable Need skills beyond applica3on programming As computer scien3sts and engineers, you will be called upon to build system so6ware Learn how to build efficient applica3ons By learning how the underlying system works

Why Learn C? Java (Also applies to Python, JavaScript, PHP ) Designed for applica/on so(ware Goal: Ease of programming Program runs on top of Java Virtual Machine (JVM) JVM: layer of system SW that emulates an abstract machine In this abstract machine Objects float around in limitless space Objects access each other by calling (well-defined) methods Excep3ons protect objects from illegal accesses A real machine looks nothing like that

Why Learn C? C Designed for system so(ware Goal: Direct control over HW Programs run on top of bare machine Just like an assembly language program In a real machine Objects reside in memory HW (typically DRAM) Memory is a sequence of bytes with physical limits Objects accessed by read/write of memory loca3ons Illegal accesses result in data corrup3on (or crashes)

Learning C will be Painful But will make you a beyer programmer

The syllabus

The Hello World Program #include <stdio.h> int main() { printf( Hello world ); return 0; }

Data Types Integers Reals Text short int long long long float double long double char Integer types have signed or unsigned versions Examples: signed int, unsigned short, Data types derived from these basic data types Pointer, Array, Struct Will be discussed later in detail Note: no classes like in Java

Pointer Data Type Data type that holds a memory address Memory address: A number represen3ng a loca3on in memory Loca3ons in memory are numbered from 0 onwards Cf. Java has no concept of memory addresses in its abstract machine, hence no pointers Examples: float *, int *, char * float * : memory address of a loca3on holding a float float is called the base type of the pointer

Pointer Data Type Address Memory Name 0000 0001 5 y 0002 0003 0004 0005 3.14 x 0006...... Example for below code: float x = 3.14; float *y = (float*) 5; In example x resides in address 0005 Value of x is 3.14 Type of x is float y resides in address 0001 Value of y is 5 Type of y is float * y is said to point to x

Sizeof() Operator Returns the size of data type (in bytes) Examples: sizeof(int), sizeof(x), Why would you want to know this informa3on? C manipulates memory directly through addresses Layout of variables in memory becomes important in C Returned size may be different for each system Why? Underlying machine is designed for a specific size E.g. if CPU has 2-byte wide integer registers, it s more efficient to translate int types to 2-byte values Not a func3on call Compiler subs3tutes sizeof() to a number during transla3on (Taking into considera3on design of target machine) No cost associated with it do not try to hardcode a number!

Sizeof() for Various Systems Data Type C Standard 32-bit Windows 64-bit Unix/Linux 64-bit char 8 bits 8 bits 8 bits 8 bits short at least 16 bits 16 bits 16 bits 16 bits int at least 16 bits 32 bits 32 bits 32 bits long at least 32 bits 32 bits 32 bits 64 bits long long at least 64 bits 64 bits 64 bits 64 bits sizeof(char)? Always 1 sizeof(int)? Depends on the compiler, but at least 2 according to Standard C sizeof(char*)? (char pointer) Again, depends on the compiler, but usually 4 (32 bits) on 32-bit machines, and 8 (64 bits) on 64-bit machines