CMPSC 311- Introduction to Systems Programming Module: Systems Programming

Similar documents
CMPSC 311- Introduction to Systems Programming Module: Systems Programming

CMPSC 311- Introduction to Systems Programming Module: Systems Programming

CSE 333 Lecture 1 - Systems programming

CSE 333 Lecture 1 - Systems programming

Chapter 3: Operating-System Structures

Computer Basics 1/6/16. Computer Organization. Computer systems consist of hardware and software.

Computer Basics 1/24/13. Computer Organization. Computer systems consist of hardware and software.

OS and Computer Architecture. Chapter 3: Operating-System Structures. Common System Components. Process Management

Last class: OS and Architecture. OS and Computer Architecture

Last class: OS and Architecture. Chapter 3: Operating-System Structures. OS and Computer Architecture. Common System Components

Operating System Services. User Services. System Operation Services. User Operating System Interface - CLI. A View of Operating System Services

Module 3: Operating-System Structures. Common System Components

CHAPTER 1 Introduction to Computers and Java

Module 3: Operating-System Structures

Chapter 3: Operating-System Structures

What are some common categories of system calls? What are common ways of structuring an OS? What are the principles behind OS design and

Operating-System Structures

Operating-System Structures

Last 2 Classes: Introduction to Operating Systems & C++ tutorial. Today: OS and Computer Architecture

MODERNIZATION C++ Bjarne Stroustrup, creator of C++

Chapter 2. Operating-System Structures

Chapter 2: Operating-System Structures

Objectives. Chapter 2: Operating-System Structures. 2.1 Operating System Services

Memory Management! Goals of this Lecture!

Operating Systems. Operating Systems

Computer Organization & Assembly Language Programming

Unit 2 : Computer and Operating System Structure

Operating System Review

OPERATING SYSTEMS UNIT - 1

The Operating System. Chapter 6

Chapter 2: Operating-System Structures. Chapter 2: Operating-System Structures. Objectives. Operating System Services

Mon Sep 17, 2007 Lecture 3: Process Management

Introduction to OS (cs1550)

Introducing the Haiku Operating System

VALLIAMMAI ENGINEERING COLLEGE

CSE Traditional Operating Systems deal with typical system software designed to be:

Operating System Services

CPS 210: Operating Systems

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edit9on

Operating Systems 2010/2011

Kernels & Processes The Structure of the Operating System

Lecture 1 Introduction (Chapter 1 of Textbook)

Student Name:.. Student ID... Course Code: CSC 227 Course Title: Semester: Fall Exercises Cover Sheet:

Operating Systems. read the warning about the size of the project make sure you get the 6 th edition (or later) of the book

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Chapter 3: Operating-System Structures

Chapter 2: Operating-System Structures

Introduction. CS 2210 Compiler Design Wonsun Ahn

Evolution of Virtual Machine Technologies for Portability and Application Capture. Bob Vandette Java Hotspot VM Engineering Sept 2004

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

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?

Introduction to Concurrent Software Systems. CSCI 5828: Foundations of Software Engineering Lecture 08 09/17/2015

Computer Systems and Networks. ECPE 170 University of the Pacific

Overview. Rationale Division of labour between script and C++ Choice of language(s) Interfacing to C++ Performance, memory

Lecture 1. CMSC 412 S17 (lect 1)

OPERATING SYSTEMS. Prescribed Text Book Operating System Principles, Seventh Edition By Abraham Silberschatz, Peter Baer Galvin and Greg Gagne

Operating Systems (2INC0) 2018/19. Introduction (01) Dr. Tanir Ozcelebi. Courtesy of Prof. Dr. Johan Lukkien. System Architecture and Networking Group

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

Systems I: Programming Abstractions

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

Chapter 2: System Structures

UNIT 2. OPERATING SYSTEM STRUCTURES

Introduction to Concurrent Software Systems. CSCI 5828: Foundations of Software Engineering Lecture 12 09/29/2016

Introduction to Computer Systems and Operating Systems

Chapter 2: Operating-System Structures

Introduction to Java Programming

Chris Riesbeck, Fall Introduction to Computer Systems

Final Lecture. A few minutes to wrap up and add some perspective

CSC 453 Operating Systems

Chapter 1: Introduction

CS30002: Operating Systems. Arobinda Gupta Spring 2017

Computer Organization & Assembly Language Programming (CSE 2312)

Introduction CHAPTER. Practice Exercises. 1.1 What are the three main purposes of an operating system? Answer: The three main puropses are:

CS 261 Fall Mike Lam, Professor. Virtual Memory

Distributed Systems CSCI-B 534/ENGR E-510. Spring 2019 Instructor: Prateek Sharma

Chapter 2: Operating-System Structures

Why Operating Systems? Topic 3. Operating Systems. Why Operating Systems? Why Operating Systems?

Introduction to System Programming

Free Downloads The C++ Programming Language: Special Edition (3rd Edition)

Parallel Algorithm Engineering

Fiji VM Safety Critical Java

DISTRIBUTED SYSTEMS. Instructor: Prasun Dewan (FB 150,

COURSE PLAN Regulation: R11 FACULTY DETAILS: Department::

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

To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edition

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

Some popular Operating Systems include Linux Operating System, Windows Operating System, VMS, OS/400, AIX, z/os, etc.

The Host Environment. Module 2.1. Copyright 2006 EMC Corporation. Do not Copy - All Rights Reserved. The Host Environment - 1

Operating Systems. Overview. Dr Alun Moon. Computing, Engineering and Information Sciences. 27th September 2011

Operating Systems (ECS 150) Spring 2011

Chapter 2: Operating-System

Windows 7 Overview. Windows 7. Objectives. The History of Windows. CS140M Fall Lake 1

Chapter 2: System Structures. Operating System Concepts 9 th Edition

Chapter 2: Operating-System Structures

Chapter 2 Operating-System Structures

Distributed Systems 16. Distributed File Systems II

Elements of Computers and Programming Dr. William C. Bulko. What is a Computer?

Introduction to Computing Systems - Scientific Computing's Perspective. Le Yan LSU

Transcription:

CMPSC 311- Introduction to Systems Programming Module: Systems Programming Professor Patrick McDaniel Fall 2015

WARNING Warning: for those not in the class, there is an unusually large number of people trying to get in (4x more than any other year). I cannot make any promises that everyone will get into the class due to others dropping.

Software Systems A platform, application, or other structure that: is composed of multiple modules the system s architecture defines the interfaces of and relationships between the modules usually is complex in terms of its implementation, performance, management hopefully meets some requirements Performance Security Fault tolerance Data consistency These are properties of computer systems that people design, optimize, and test for. Some refer to the as "ilities (pronounced "ill-it-tees") 3

100,000 Foot View of Systems C application C++ application Java application OS / app interface (system calls) HW/SW interface (x86 + devices) C standard library (glibc) C++ STL / boost / standard library operating system hardware CPU memory storage network GPU clock audio radio peripherals JRE 4

A layered view provides service to layers above client client client your system understands and relies on layers below layer below layer below 5

A layered view more useful, portable, reliable abstractions client client client your system constrained by performance, footprint, behavior of the layers below layer below layer below 6

Example system Operating system a software layer that abstracts away the messy details of hardware into a useful, portable, powerful interface modules: file system, virtual memory system, network stack, protection system, scheduling subsystem,... each of these is a major system of its own! design and implementation has many engineering tradeoffs e.g., speed vs. (portability, maintainability, simplicity) 7

Another example system Web server framework a software layer that abstracts away the messy details of OSs, HTTP protocols, database and storage systems to simplify building powerful, scalable Web services modules: HTTP server, HTML template system, database storage, user authentication system,... also has many, many tradeoffs programmer convenience vs. performance simplicity vs. extensibility Note: we will focus on the OS system this semester. 8

Systems and Layers Layers are collections of system functions that support some abstraction to service/app above Hides the specifics of the implementation of the layer Hides the specifics of the layers below Abstraction may be provided by software or hardware Examples from the OS layer processes files virtual memory 9

A real world abstraction... What does this thing do? What about this? 10

What makes a good abstraction? An abstraction should match cognitive model of users of the system, interface, or resources Cognitive science is concerned with understanding the processes that the brain uses to accomplish complex tasks including perceiving, learning, remembering, thinking, predicting, inference, problem solving, decision making, planning, and moving around the environment. --Jerome Busemeyer

How humans think (vastly simplified) Our brain s receive sensor data to perceive and categorize environment (pattern matching and classification) Things that are easy to assimilate (learn) are close to things we already know The simpler and more generic the object, the easier (most of the time) it is to classify See human factors, physiology, and psychology classes..

A good abstraction Why do computers have a desktop with files, folders, trash bins, panels, switches and why not streets with buildings, rooms, alleys, dump-trucks, levers,

In class exercise In groups of three to four: Desktops are outlawed by the computer police You are to come up with alternate abstractions for: Data objects (i.e., replacements for files and directories) Be ready to explain in 30 seconds your environment, what are the metaphors, and why they are appropriate given user s cognitive models. Bonus for being innovative and timely

Computer system abstractions What are the basic abstractions that we use (and don t even think about) for modern computer systems?

Processes Processes are independent programs running concurrently within the operating systems The execution abstraction provides is that it has sole control of the entire computer (a single stack and execution context) Tip: if you want to see what processes are running on your UNIX system, use the ps command, e.g., ps -ax. 16

Files A file is an abstraction of a read only, write only, or ready/write data object. A data file is a collection of data on some media often on secondary storage (hard disk) Files can be much more: in UNIX nearly everything is a file Devices like printers, USB buses, disks, etc. System services like sources of randomness (RNG) Terminal (user input/out devices) Tip: /dev directory of UNIX contains real and virtual devices, e.g., ls /dev. 17

Virtual Memory The virtual memory abstraction provides control over an imaginary address space Has a virtual address space which is unique to the process The OS/hardware work together to map the address on to... Physical memory addresses Addresses on disk (swap space) Advantages Avoids interference from other processes swap allows more memory use than physically available 18

Byte-Oriented Memory Organization Programs Refer to Virtual Addresses Conceptually very large array of bytes Actually implemented with hierarchy of different memory types System provides address space private to particular process Program being executed Program can clobber its own data, but not that of others Compiler + Run-Time System Control Allocation Where different program objects should be stored All allocation within single virtual address space 19

Machine Words Machine Has Word Size Nominal size of integer-valued data Including addresses Many traditional machines use 32 bits (4 bytes) words Limits addresses to 4GB Becoming too small for memory-intensive applications Recent systems use 64 bits (8 bytes) words Potential address space 1.8 X 1019 bytes x86-64 machines support 48-bit addresses: 256 Terabytes Machines support multiple data formats Fractions or multiples of word size Always integral number of bytes 20

Word-Oriented Memory Organization Addresses Specify Byte Locations Address of first byte in word Addresses of successive words differ by 4 (32-bit) or 8 (64-bit) 32-bit Words Addr = 0000?? Addr = 0004?? Addr = 0008?? Addr = 0012?? 64-bit Words Addr = 0000?? Addr = 0008?? Bytes Addr. 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 21

APIs An Applications Programmer Interface is a set of methods (functions) that is used to manipulate an abstraction This is the library of calls to use the abstraction Some are easy (e.g., printf) Some are more complex (e.g., network sockets) Mastering systems programming is the art and science of mastering the APIs including: How they are used? What are the performance characteristics? What are the resource uses? What are their limitations

Example: Java Input/Output Set of abstractions that allow for different kinds of input and output Streams Tokenizers. Readers Writers Professional Java programmers know when and how to uses these to achieve their goals

Systems programming The programming skills, engineering discipline, and knowledge you need to build a system using these abstractions: programming: C (the abstraction for ISA) discipline: testing, debugging, performance analysis knowledge: long list of interesting topics concurrency, OS interfaces and semantics, techniques for consistent data management, algorithms, distributed systems,... most important: deep understanding of the layer below 24

Programming languages Assembly language / machine code (approximately) directly executed by hardware tied to a specific machine architecture, not portable no notion of structure, few programmer conveniences possible to write really, really fast code Compilation of a programming language results in executable code to be run by hardware. gcc (C compiler) produces target machine executable code (ISA) javac (Java compiler) produces Java Virtual Machine executable code 25

Programming languages Structured but low-level languages (C, C++) hides some architectural details, is kind of portable, has a few useful abstractions, like types, arrays, procedures, objects permits (forces?) programmer to handle low-level details like memory management, locks, threads low-level enough to be fast and to give the programmer control over resources double-edged sword: low-level enough to be complex, errorprone shield: engineering discipline 26

Programming languages High-level languages (Python, Ruby, JavaScript,...) focus on productivity and usability over performance powerful abstractions shield you from low-level gritty details (bounded arrays, garbage collection, rich libraries,...) usually interpreted, translated, or compiled via an intermediate representation slower (by 1.2x-10x), less control 27

Discipline Cultivate good habits, encourage clean code coding style conventions unit testing, code coverage testing, regression testing documentation (code comments!, design docs) code reviews Will take you a lifetime to learn but oh-so-important, especially for systems code avoid write-once, read-never code 28

Knowledge Tools gcc, gdb, g++, objdump, nm, gcov/lcov, valgrind, IDEs, race detectors, model checkers,... Lower-level systems UNIX system call API, relational databases, map/reduce, Django,... Systems foundations transactions, two-phase commit, consensus, handles, virtualization, cache coherence, applied crypto,... 29