Abstractions and Reality

Similar documents
Main Memory: Address Translation

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

CS61 Scribe Notes Date: Topic: Fork, Advanced Virtual Memory. Scribes: Mitchel Cole Emily Lawton Jefferson Lee Wentao Xu

Memory Management. Kevin Webb Swarthmore College February 27, 2018

CS 31: Intro to Systems Operating Systems Overview. Kevin Webb Swarthmore College March 31, 2015

Dynamic Memory: Alignment and Fragmentation

Chris Riesbeck, Fall Introduction to Computer Systems

Operating-System Structures

CS 326: Operating Systems. Process Execution. Lecture 5

CS 104 Computer Organization and Design

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Learning Objectives. A Meta Comment. Exercise 1. Contents. From CS61Wiki

Introduction to Computer Systems

Introduction to Computer Systems

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

Process Migration. David Zuercher CS555 Distributed Systems

Memory Layout for a Simple Batch System

Hardware OS & OS- Application interface

CS 31: Intro to Systems Operating Systems Overview. Kevin Webb Swarthmore College November 8, 2018

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 4: Threads and Dispatching. 4.

CSE 153 Design of Operating Systems Fall 2018

CS61 Scribe Notes Lecture 18 11/6/14 Fork, Advanced Virtual Memory

The Kernel Abstraction. Chapter 2 OSPP Part I

ECE 477 Digital Systems Senior Design Project. Module 10 Embedded Software Development

CSE 153 Design of Operating Systems

Introduction to Computer Systems

int $0x32 // call interrupt number 50

Concurrency. Johan Montelius KTH

Lec 22: Interrupts. Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University. Announcements

What is concurrency? Concurrency. What is parallelism? concurrency vs parallelism. Concurrency: (the illusion of) happening at the same time.

CS 31: Intro to Systems Caching. Martin Gagne Swarthmore College March 23, 2017

Computing and compilers

Lab 3-2: Exploring the Heap

Midterm 1. Administrivia. Virtualizing Resources. CS162 Operating Systems and Systems Programming Lecture 12. Address Translation

Section 1: Tools. Contents CS162. January 19, Make More details about Make Git Commands to know... 3

Often, more information is required when designing system call Information varies according to OS and types of system call

CS 31: Intro to Systems Processes. Kevin Webb Swarthmore College March 31, 2016

Processes. Johan Montelius KTH

Page 1. Goals for Today" Virtualizing Resources" Important Aspects of Memory Multiplexing" CS162 Operating Systems and Systems Programming Lecture 20

A Brief Git Primer for CS 350

A process. the stack

Lecture Notes for 04/04/06: UNTRUSTED CODE Fatima Zarinni.

CSE 303: Concepts and Tools for Software Development

CSE 153 Design of Operating Systems

PROCESS VIRTUAL MEMORY PART 2. CS124 Operating Systems Winter , Lecture 19

143A: Principles of Operating Systems. Lecture 5: Address translation. Anton Burtsev October, 2018

Address spaces and memory management

Introduction. CS3026 Operating Systems Lecture 01

Introduction to Operating Systems. Chapter Chapter

Lecture 2: September 9

CS510 Operating System Foundations. Jonathan Walpole

Arvind Krishnamurthy Spring Threads, synchronization, scheduling Virtual memory File systems Networking

Virtual Memory. Kevin Webb Swarthmore College March 8, 2018

CS 61 Section Notes 5

OS Structure, Processes & Process Management. Don Porter Portions courtesy Emmett Witchel

Zing Vision. Answering your toughest production Java performance questions

Fall 2017 :: CSE 306. Process Abstraction. Nima Honarmand

CS61, Fall 2012 Section 2 Notes

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

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Recall: Address Space Map. 13: Memory Management. Let s be reasonable. Processes Address Space. Send it to disk. Freeing up System Memory

C Refresher, Advance C, Coding Standard, Misra C Compliance & Real-time Programming

Introduction to System Programming

Chapter 2: Operating-System Structures

Fall 2015 COMP Operating Systems. Lab #3

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

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

Introduction to Code Optimization. Lecture 36: Local Optimization. Basic Blocks. Basic-Block Example

ELEC 377 Operating Systems. Week 1 Class 2

COS 318: Operating Systems

Writing Code and Programming Microcontrollers

Lecture 5: Concurrency and Threads

Computer Systems Organization

CSci 4061 Introduction to Operating Systems. Processes in C/Unix

Threads CS1372. Lecture 13. CS1372 Threads Fall / 10

Software Tools for Low-Level Software and Operating Systems Classes. Max Walter & Sven Karlsson Technical University of Denmark

! Software ( kernel ) that runs at all times. ! OS performs two unrelated functions: Maria Hybinette, UGA. user! 1! Maria Hybinette, UGA. user! n!

Synchronization. CS61, Lecture 18. Prof. Stephen Chong November 3, 2011

Introduction to Operating. Chapter Chapter

Embedded Systems Dr. Santanu Chaudhury Department of Electrical Engineering Indian Institute of Technology, Delhi

Parallel Programming using OpenMP

Message Passing Interface (MPI)

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

2 Introduction to Processes

CPSC 213. Introduction to Computer Systems. The Operating System. Unit 2e

Administrivia. Lab 1 due Friday 12pm. We give will give short extensions to groups that run into trouble. But us:

CS 61C: Great Ideas in Computer Architecture. Lecture 23: Virtual Memory. Bernhard Boser & Randy Katz

OS structure. Process management. Major OS components. CSE 451: Operating Systems Spring Module 3 Operating System Components and Structure

Review: Easy Piece 1

Process Address Spaces and Binary Formats

Chapter 2: Operating-System Structures

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

CS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019

Introduction to Operating Systems. Chapter Chapter

CS , Spring 2009 Exam 2

An Overview of the BLITZ System

Parallel Programming using OpenMP

Protection. - Programmers typically assume machine has enough memory - Sum of sizes of all processes often greater than physical memory 1 / 36

CS/SE3SH3 Operating Systems

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

Transcription:

Abstractions and Reality Learning Objectives (i.e., after reviewing this presentation, you should be able to: ) Describe some ways that the abstraction provided by the C language is similar to and different from the abstraction provided by the underlying machine. Explain the difference between a program and a process. Visualize how memory is arranged in a process. Write simple programs to help you answer questions about how memory is arranged in a process. 9/8/2015 CS61 Fall 2015 1

Getting Started The code examples used here can be found in the cs61-videos repository in the abstractions directory. You should already have your class appliance set up. You should then be able to clone the repository: git clone git://code.seas.harvard.edu/cs61/cs61-videos 9/8/2015 CS61 Fall 2015 2

Abstractions Everywhere Programming and computer science is chock full of abstractions. Abstractions are a way to: Manage complexity Make the unfamiliar familiar Separate relevant from irrelevant details But, abstractions also have a cost: Sometimes they incur overhead (e.g., speed, memory) Sometimes they hide power 9/8/2015 CS61 Fall 2015 3

Some abstractions A web application framework A database Collections of objects The C language Assembly language A processor architecture 9/8/2015 CS61 Fall 2015 4

The Abstractions We ll Examine The C language & assembly language Programming languages provide an abstraction that lets humans express the meaning of a program. The language definition of C is higher level than that of assembly language, but both are still designed for humans. Compilers transform C into assembly language. Assemblers then transform assembly language into machine code, targeting a specific A processor architecture A machine implements some processor architecture There can be multiple implementations of an architecture 9/8/2015 CS61 Fall 2015 5

Why bother? I m perfectly happy with my abstractions, why bother looking under the covers? Understanding the real machine helps us understand why some programs are fast/slow. It helps us understand how things go wrong. The real machine is more powerful with power comes responsibility it is also in some ways more dangerous 9/8/2015 CS61 Fall 2015 6

9/8/2015 CS61 Fall 2015 7

Language and Machine Abstractions 1. I want to print Hello World! to the screen. 2. I write a C program. 3. The compiler translated the C into assembly 4. An assembler translated the assembly into machine code 5. A linker combined the machine code with library information to create an executable file. 6. The OS created a process in which to execute that file. 7. Hello World! appeared. 9/8/2015 CS61 Fall 2015 8

From Program to Process A process is the realization of a program executing on a machine. It is an abstraction, provided by the operating system. Provides isolation (you and I can both run things and they don t interfere with each other). Makes it look like nothing else is running except the process. Makes it appear as if the process runs from start to end without interruption. But this is all an illusion! Many processes might be running. A process can be interrupted. 9/8/2015 CS61 Fall 2015 9

9/8/2015 CS61 Fall 2015 10

But what is a process? A process is composed of two parts: A part that keeps track of stuff : Address space A dynamic part: Thread Address space: A place in which execution happens. The set of addresses (e.g., memory locations) to which a running computation has access. An address space can be physical (addresses map directly to locations in the hardware) or virtual (addresses are make believe but get translated into locations in hardware). Address spaces provide protection boundaries. 9/8/2015 CS61 Fall 2015 11

9/8/2015 CS61 Fall 2015 12

The Address Space 0xFFFFFFFF Kernel virtual memory User Stack Memory mapped region for shared libraries Heap Read/write data Local: 0xbf------ Global: 0x0804a024 Const Global: 0x08048870 Heap: 0x08------ (> Global) Main: 0x080484a0 Printf: 0xb7e674a0 0x08048000 0 Read-only code and data 9/8/2015 CS61 Fall 2015 13

Summing in up The C language presents an abstract machine that lets a human express a computation. Tools (system programs) transform that expression into an executable that the operating system knows how to execute. The operating system creates a process to execute that program. The process lives in the memory of a real machine. The real machine reads instructions and data from that memory and executes the instructions. 9/8/2015 CS61 Fall 2015 14