CS 5523: Operating Systems

Similar documents
Processes. Criteria for Comparing Scheduling Algorithms

Cyber-Physical Systems Scheduling

File Systems: Fundamentals

Final Review. Chenyang Lu. CSE 467S Embedded Compu5ng Systems

Operating Systems. Chenyang Lu

CS 2461: Computer Architecture I

Virtual Memory and Address Translation

CS 5523 Operating Systems: Synchronization in Distributed Systems

Real-Time Scheduling Single Processor. Chenyang Lu

A Micro-Benchmark Evaluation of Catamount and Cray Linux Environment (CLE) Performance

Real-Time CORBA. Chenyang Lu CSE 520S

Last Time. Bit banged SPI I2C LIN Ethernet. u Embedded networks. Ø Characteristics Ø Requirements Ø Simple embedded LANs

CS 5523 Operating Systems: Intro to Distributed Systems

CSE 520S Real-Time Systems

Concurrent Programing: Why you should care, deeply. Don Porter Portions courtesy Emmett Witchel

Adaptive QoS Control for Real-Time Systems

Optimization Strategies

Servilla: Service Provisioning in Wireless Sensor Networks. Chenyang Lu

Priority Queues & Heaps

Priority Queues & Heaps

Downloaded from: justpaste.it/vlxf

The optical memory card is a Write Once media, a written area cannot be overwritten. Information stored on an optical memory card is non-volatile.

Priority Queues & Heaps

OPEN SOURCE CRYPTOCURRENCY

Maps and Hash Tables. EECS 2011 Prof. J. Elder - 1 -

CS 5523: Operating Systems

Introduction to VI-HPS

Critiques. Ø Critique #1

TinyOS and nesc. Ø TinyOS: OS for wireless sensor networks. Ø nesc: programming language for TinyOS.

HPCG on Tianhe2. Yutong Lu 1,Chao Yang 2, Yunfei Du 1

Midterm Review. EECS 2011 Prof. J. Elder - 1 -

IN THE UNITED STATES DISTRICT COURT FOR THE EASTERN DISTRICT OF TEXAS MARSHALL DIVISION

SMS based Voting System

Batch binary Edwards. D. J. Bernstein University of Illinois at Chicago NSF ITR

Ø Project Description. Ø Design Criteria. Ø Design Overview. Ø Design Components. Ø Schedule. Ø Testing Criteria. Background Design Implementation

Kjell-Einar Anderssen. Country Manager Norway - Nutanix

Product Description

Comparison Sorts. EECS 2011 Prof. J. Elder - 1 -

Maps, Hash Tables and Dictionaries

Chapter 8: Recursion

New features in Oracle 11g for PL/SQL code tuning.

DevOps Course Content

Performance & Energy

Title Author Edition

4th International Industrial Supercomputing Workshop Supercomputing for industry and SMEs in the Netherlands

Exploring QR Factorization on GPU for Quantum Monte Carlo Simulation

Estonian National Electoral Committee. E-Voting System. General Overview

IMPLEMENTATION OF SECURE PLATFORM FOR E- VOTING SYSTEM

Ownership of Site; Agreement to Terms of Use

Civil Justice Improvements (CJI) Committee. Update #2

A Bloom Filter Based Scalable Data Integrity Check Tool for Large-scale Dataset

LEGAL TERMS OF USE. Ownership of Terms of Use

Agreement for iseries and AS/400 System Restore Test Service

FM Legacy Converter User Guide

Philips Lifeline. Ø Chenyang Lu 1

General Framework of Electronic Voting and Implementation thereof at National Elections in Estonia

Wednesday, January 4, electronic components

TAFTW (Take Aways for the Week) APT Quiz and Markov Overview. Comparing objects and tradeoffs. From Comparable to TreeMap/Sort

Key Considerations for Implementing Bodies and Oversight Actors

Last Time. Embedded systems introduction

UNITED STATES DISTRICT COURT CENTRAL DISTRICT OF CALIFORNIA CIVIL MINUTES GENERAL

Text UI. Data Store Ø Example of a backend to a real Could add a different user interface. Good judgment comes from experience

Deadlock. deadlock analysis - primitive processes, parallel composition, avoidance

Software License Agreement for Beckhoff Software Products

Supreme Court of Florida

MAPR END USER LICENSE AGREEMENT Last updated: April 20, 2016

We should share our secrets

Internet of Things Wireless Sensor Networks. Chenyang Lu

Implementing Domain Specific Languages using Dependent Types and Partial Evaluation

IC Chapter 15. Ballot Card and Electronic Voting Systems; Additional Standards and Procedures for Approving System Changes

FairCom Press Release Archive:

Lab 11: Pair Programming. Review: Pair Programming Roles

Recommendations For Reddit Users Avideh Taalimanesh and Mohammad Aleagha Stanford University, December 2012

A Calculus for End-to-end Statistical Service Guarantees

IF YOU DO NOT AGREE TO THESE TERMS, DO NOT DOWNLOAD, INSTALL OR USE BSC.

14 Managing Split Precincts

I do not wish to feud I am very sad about the Jefferson County Schools dilemma and definitely want it to settle down.

COMP 635: WIRELESS & MOBILE COMMUNICATIONS COURSE INTRODUCTION. Jasleen Kaur. Fall 2017

Key Considerations for Oversight Actors

Learning Systems. Research at the Intersection of Machine Learning & Data Systems. Joseph E. Gonzalez

Platform independent proc interface

Search Trees. Chapter 10. CSE 2011 Prof. J. Elder Last Updated: :51 PM

Installation of InfraStruXure for Medium Data Centers with an Emergency Power Off Circuit

The HeLIx + inversion code Genetic algorithms. A. Lagg - Abisko Winter School 1

Act means the Municipal Elections Act, 1996, c. 32 as amended;

M-Vote (Online Voting System)

SOFTWARE END USER LICENSE AGREEMENT (Load Systems Software and Firmware)

Hoboken Public Schools. College Algebra Curriculum

Outline. Your Project Proposal an evolving plan. Project Proposal Guidelines (2 files) ECE496 Design Project Preparing Your Project Proposal

IF YOU DO NOT AGREE TO THESE TERMS, DO NOT DOWNLOAD, INSTALL OR USE BSC.

Category-level localization. Cordelia Schmid

US MOBILE NEWS SEEKING TRENDS. Based on October September 2015 data. Excerpted from a full findings report delivered November 2015.

Title: Local Search Required reading: AIMA, Chapter 4 LWH: Chapters 6, 10, 13 and 14.

IceCube Project Monthly Report November 2007

Exhibit No. 373A-06 to IBM Vendor Access Agreement Page 1 of 5

The Digital Appellate Court Introduction to the edca Electronic Portal

LOCAL LAW NO.: OF 2016

Lecture 6 Cryptographic Hash Functions

Midterm Review. EECS 2011 Prof. J. Elder - 1 -

Case3:10-cv JW Document81 Filed06/12/12 Page1 of 23 SAN FRANCISCO DIVISION

Transcription:

Lecture1: OS Overview CS 5523: Operating Systems Instructor: Dr Tongping Liu Midterm Exam: Oct 2, 2017, Monday 7:20pm 8:45pm Operating System: what is it?! Evolution of Computer Systems and OS Concepts Different types/variations of Systems/OS Ø Parallel/distributed/real-time/embedded OS etc OS as a resource manager Ø How does OS provide service? interrupt/system calls OS Structures and basic components Ø Process/memory/IO device managers Basic design approaches Ø Monolithic/layered/microkernel/virtual machine etc CS5523: Operating Systems @ UTSA 1 CS5523: Operating Systems @ UTSA 2 Components in Operating System Process/thread Management Ø CPU (processors): most precious resource Memory Management Ø Main memory File Management à data /program Secondary-Storage Management à disk I/O System Management à I/O devices Protection and Security à access management I/O devices 3 OS Interface: APIs and System Calls For application programmers Application programming interface (API) Ø The run-time support system (run-time libraries) provides a system-call interface, that intercepts function calls in the API and invokes the necessary system call within the operating system System calls provide the interface between a running program and the operating system Ø Generally available in routines written in C and C++ Ø Certain low-level tasks may have to be written using assembly language 4 1

Types of System Calls Process control" File management" Device management" Information maintenance" Communications" Protection" " Interrupt Mechanisms Save the current process state Interrupt transfers control to the interrupt service routine (ISR) generally through interrupt vector containing the addresses of all the service routines ISR: Separate segments of code determine what action should be taken for each type of interrupt Once the interrupt has been serviced by the ISR, the control is returned to the interrupted program 6 Basic Interrupt Processing 1 The interrupt is issued 2 Processor finishes execution of current instruction 3 Processor signals acknowledgement of interrupt 4 Processor pushes PSW(Program Status Word) and PC to control stack 5 Processor loads new PC value through the interrupt vector 6 ISR saves remainder of the process state information 7 ISR executes 8 ISR restores process state information 7 9 Old PSW and PC values are restored from the control stack Lecture2: Process Management Basic concepts of process Ø Process control block (PCB) and address space Basic operations for process management Ø Process creation/termination States of process: different queues Ø ready, running, or wait etc Ø Context switch: multiple hardware running contexts Scheduling of process: CPU scheduling Ø Basic scheduling algorithms: FIFO, SJF etc Inter process communication Ø shared memory and message CS5523: Operating Systems @ UTSA 8 2

Process vs Program Program: a set of functions Ø a passive entity Ø stored as files on disk Process: a program in execution Ø Dynamic concept: running of a program How do we run a program? What are steps to create a process? Process: Running Context Registers: in addition to general registers Ø Program Counter (PC): contains the memory address of the next instruction to be executed Ø Stack Pointer (SP): points to the top of the current stack in memory The stack contains one frame for each procedure that has been entered but not yet exited Ø Program Status Word (PSW): is an IBM System/360 architecture and successors control register, which performs the function of a Status register and Program counter in other architectures Higher level resources: open files etc Synchronization and communication resource: semaphores and sockets 9 10 Example: PCB in Linux (task_struct) Context Switch Process Management Registers Program Counter Stack Pointers Process State Priority Scheduling Parameters (slice) Process ID Parent process Process group Time when process started CPU time used Memory Management Pointer to text (code) segment Pointer to data segment Pointer to stack segment File Management Root directory Working directory User Id Group Id List of open files When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process via a context switch! Context of a process represented in the PCB" Context-switch time is overhead" Ø 1 ~ 1000 ms" Hardware support" Ø Multiple set of registers" Other performance issues/problems" Ø Cache content: locality is lost" Ø TLB content: may need to flush" 11 3

Process Creation An Example: Unix fork( ) Address space" Ø Child duplicate its parent (data, program)" Ø Child has a program loaded into it (exec())" Execution" Ø Parent and children execute concurrently" Ø Parent waits until children terminate" Resource sharing: complicated" Ø Shared open files, but not descriptors" Ø Different page tables" Text pid = 25 Data Stack Process Status < > int cpid = fork( ); if (cpid = = 0) { <child code> exit(0); } <parent code> wait(cpid); File File Resources Resources Text pid = 26 Data Stack Process Status cpid = 26 < > int cpid = fork( ); if (cpid = = 0) { <child code> exit(0); } <parent code> wait(cpid); cpid = 0 UNIX kernel 14 Activities in Processes Bursts of CPU usage alternate with periods of I/O wait CPU-bound: high CPU utilization, interrupts are processed slowly I/O-bound: more time is spending on requesting data than processing it Process 1: CPU bound" Process 2:" I/O bound" Time" CPU bursts" Total CPU usage" I/O waits" Total CPU usage" 15 Classical Scheduling Algorithms FCFS: non-preemptive, based on arrival time Ø Long waiting time, eg long process before SSH console? SJF(shortest job first): preemptive & non-preemptive Ø Optimal in term of waiting time RR (Round-robin): preemptive Ø Processes take turns with fixed time quantum eg, 10ms Priority-based scheduling Ø Real-time systems: earliest deadline first (EDF) Multi-level queue (priority classes) Ø System processes >faculty processes >student processes Multi-level feedback queues: short à long quantum 16 4

Inter-Process Communication (IPC) Processes within a system may be independent or cooperating! Cooperating process can affect or be affected by other processes" Reasons for cooperating processes:" Ø Information sharing, eg, sharing a file" Ø Computation speedup, eg, subtasks for parallelism" Ø Modularity & Convenience ( eg, editing, printing in the same time)" Cooperating processes need inter-process communication (IPC)" Ø Shared memory" Ø Pipe and Named Pipe" Ø Message passing" Lecture 3: Memory Management Outline Simple memory management: swap etc Virtual memory and paging Ø Page table and address translation Ø Translation lookaside buffer (TLB) Multi-level page table Page replacement algorithms and modeling Working set of processes " Department of Computer Science @ UTSA 18 Motivations for Virtual Memory Use physical DRAM as cache for the disk" Ø Virtual pages of processes can exceed physical memory size" Simplify memory management" Ø Multiple processes resident in main memory" ü Each with its own address space" Ø Only active code and data is actually in memory" Provide protection" Ø One process can t interfere with another" ü Because they operate in different address spaces" Ø User process cannot access privileged information" ü Different sections of address spaces have different permissions" Address Translation Architecture CPU Virtual address page number page offset p d page table 0 1 p-1 p f frame number f d physical address How big the page table is? 0 1 f-1 f f+1 f+2 physical memory 20 5

Page Table Size Memory Requirement of Page Tables Modern Systems/Applications Ø 32 bits virtual address Ø System with 1GB physical memory à 30 bits physical address Ø Suppose the size of one page/frame is 4KB (12 bits) Page table size Ø # of virtual pages: 32 12 = 20 bits à 2 20 PTEs Ø Page table size = PTE size * 2 20 = 4 MB per process à 2 10 frames If there are 128 processes Ø Page tables occupy 128 * 4MB = 512 MB Ø 50% of memory will be used by page tables? How can we get smaller page table?! Only the 1 st level page table and the required 2 nd level page tables need to be in memory Example: a process with working-set size of 32 MB (recall that 1GB memory and 32 bits virtual address) Ø 4KB / page à process has 8KB (8*2 10 ) virtual pages Ø One 2 nd level page table maps 2 10 pages; Ø Number (minimum) of 2 nd level page table needed: 8 Ø Total (minimum) memory for page table: 1 st level page table + 8; in total of 9 page tables à 9 X 4KB = 36 KB Department of Computer Science @ UTSA 21 Department of Computer Science @ UTSA 22 Page table size 32bit machine, page size 4k, each entry 4 bytes, one level page table (full 4GB linear address) Page table size = 2^20 pages = 2^22 = 4M 32bit machine, page size 4k, each entry 4 bytes, two level page table (two apges:0x0000000, and 0xFFFFF000) Page table size = (2^10 level-0 entries) *4bytes + (2^10 level-1 entries * 4 bytes) * 2 = 12 Kbytes Size of Page/Frame: How Big? Determined by number of bits in offset (12Bità4KB) Smaller pages have advantages Ø Less internal fragmentation Ø Better fit for various data structures, code sections Larger pages are better because Ø Less overhead to keep track of them Ø More efficient to transfer larger pages to and from disk One principle: page table à fit into one frame 32bits machine, 10 bits for each level How can we make the address translation faster? 23 Department of Computer Science @ UTSA 24 6

Integrating TLB and Cache Translation Lookaside Buffer (TLB)" CPU hit VA PA miss TLB Cache Lookup miss Translation hit data Main Memory Working-Set Model Δ working-set window a fixed number of page references, example: 10,000 instruction" WSS i (working set of Process P i ) = total number of pages referenced in the most recent Δ " Ø if Δ too small, will not encompass entire locality" Ø if Δ too large, will encompass localities" Ø if Δ = will encompass entire program" D = Σ WSS i total demand frames " if D > (available frames) m Thrashing" Thus, if D > m, then suspend one of the processes" Page Replacement Algorithms Summary: Page Replacement Algorithms How to select the victim frame?" Ø You can select any frame, the page replacement will work; but the performance???" Ø Gives the lowest page-fault rate" Evaluate an algorithm by running it on a particular string of memory references (reference string) and compute the number of page faults on that string" "In all our examples, we will have 3 frames and the following reference string" Algorithm FIFO (First-In, First Out) Second chance LRU (Least Recently Used) OPT (Optimal) Comment Might throw out useful pages Big improvement over FIFO Excellent, but hard to implement exactly Not implementable, but useful as a benchmark Department of Computer Science @ UTSA 28 7

Page Allocation Buddy Allocation Example: Need to allocate 65 contiguous page frames" Ø Look in list of free 128-page-frame blocks " Ø If free block exists, allocate it, else look in next highest order list (here, 256-page-frame blocks)" Ø If first free block is in 256-page-frame list, allocate a 128- page-frame block and put remaining 128-page-frame block in lower order list" Ø If first free block is in 512-page-frame list, allocate a 128- page-frame block and split remaining 384 page frames into 2 blocks of 256 and 128 page frames These blocks are allocated to the corresponding free lists" Question: What is the worst-case internal fragmentation?" 29 Buddy De-Allocation When blocks of page frames are released the kernel tries to merge pairs of buddy blocks of size b into blocks of size 2b" Two blocks are buddies if:" Ø They have equal size b" Ø They are located at contiguous physical addresses" Ø The address of the first page frame in the first block is aligned on a multiple of 2b*2 12 " The process repeats by attempting to merge buddies of size 2b, 4b, 8b etc " Slab Allocator Performs the following functions" Ø Allocate memory" Ø Initialize objects/structures" Ø Use objects/structures" Ø Deconstruct objects/structures" Ø Free memory" /proc/slabinfo gives full information about memory usage on the slab level (see also /usr/bin/slabtop)" 8

Types of questions on Midterm1 Question answering: Ø Example: What is a system call? Problem Analysis: Ø Example: drawing the Gantt chart for FIFO scheduler CS5523: Operating Systems @ UTSA 33 9