Operating Systems. Operating System Structure. Lecture 2 Michael O Boyle

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

CSE 451: Operating Systems Winter Module 2 Architectural Support for Operating Systems

Even coarse architectural trends impact tremendously the design of systems

Even coarse architectural trends impact tremendously the design of systems. Even coarse architectural trends impact tremendously the design of systems

OS concepts and structure. q OS components & interconnects q Structuring OSs q Next time: Processes

Architecture and OS. To do. q Architecture impact on OS q OS impact on architecture q Next time: OS components and structure

Even coarse architectural trends impact tremendously the design of systems

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

CS 537 Lecture 2 Computer Architecture and Operating Systems. OS Tasks

CSE 120 Principles of Operating Systems

CSE 120 Principles of Operating Systems

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

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

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

Chapter 2 Operating-System Structures

Operating System Architecture. CS3026 Operating Systems Lecture 03

Hardware OS & OS- Application interface

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

Lecture 2: Architectural Support for OSes

Architectural Support for Operating Systems. Jinkyu Jeong ( Computer Systems Laboratory Sungkyunkwan University

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

ELEC 377 Operating Systems. Week 1 Class 2

TDDI04, K. Arvidsson, IDA, Linköpings universitet Operating System Structures. Operating System Structures Overview. Operating System Services

COS 318: Operating Systems

Architectural Support for Operating Systems

Chapter 2. Operating-System Structures

Chapter 2: Operating-System Structures

Anne Bracy CS 3410 Computer Science Cornell University

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

CSE 153 Design of Operating Systems Fall 18

Operating-System Structures

Unit 2 : Computer and Operating System Structure

Chapter 3: Operating-System Structures

Operating-System Structures

COS 318: Operating Systems

Anne Bracy CS 3410 Computer Science Cornell University

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

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

CSE 153 Design of Operating Systems

Architectural Support for Operating Systems

Operating-System Structures

Chapter 3: Operating-System Structures

Chapter 2: Operating-System Structures

CHAPTER 2: SYSTEM STRUCTURES. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Chapter 2: Operating-System Structures

Chapter 3: Operating-System Structures

Four Components of a Computer System

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - II OS Structures. University at Buffalo. OS Design and Implementation

OS Design Approaches. Roadmap. System Calls. Tevfik Koşar. Operating System Design and Implementation. CSE 421/521 - Operating Systems Fall 2013

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

Chapter 2: Operating-System Structures

Module 3: Operating-System Structures. Common System Components

CSCI 6730 / 4730 Operating Systems. Key Questions in System Design. Review: What is An Operating System? Key Points

CSC 453 Operating Systems

Chapter 2: Operating-System

OS Design Approaches. Roadmap. OS Design Approaches. Tevfik Koşar. Operating System Design and Implementation

The Kernel Abstraction

OS Structure. Hardware protection & privilege levels Control transfer to and from the operating system

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

CS 5460/6460 Operating Systems

Operating Systems Structure and Processes Lars Ailo Bongo Spring 2017 (using slides by Otto J. Anshus University of Tromsø/Oslo)

Chapter 2: Operating-System Structures

CPSC/ECE 3220 Fall 2017 Exam Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.

Operating Systems ECE344

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

Lecture Topics. Announcements. Today: Operating System Overview (Stallings, chapter , ) Next: Processes (Stallings, chapter

Operating Systems. Introduction & Overview. Outline for today s lecture. Administrivia. ITS 225: Operating Systems. Lecture 1

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals

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

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

Process Description and Control

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

CS 390 Chapter 2 Homework Solutions

Computer System Architecture. CMPT 300 Operating Systems I. Summer Segment 3: Computer System Architecture. Melissa O Neill

9/19/18. COS 318: Operating Systems. Overview. Important Times. Hardware of A Typical Computer. Today CPU. I/O bus. Network

Microkernels and Client- Server Architectures

The Kernel Abstraction. Chapter 2 OSPP Part I

Lecture 2 Fundamental OS Concepts. Bo 2018, Spring

Chapter 2: System Structures

Hakim Weatherspoon CS 3410 Computer Science Cornell University

CSC Operating Systems Fall Lecture - II OS Structures. Tevfik Ko!ar. Louisiana State University. August 27 th, 2009.

Announcements. Computer System Organization. Roadmap. Major OS Components. Processes. Tevfik Ko!ar. CSC Operating Systems Fall 2009

System Call. Preview. System Call. System Call. System Call 9/7/2018

Inf2C - Computer Systems Lecture 16 Exceptions and Processor Management

Syscalls, exceptions, and interrupts, oh my!

Introduction. CS3026 Operating Systems Lecture 01

CS5460: Operating Systems

The Slide does not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams.

Operating Systems CS3502 Spring 2018

Why use an Operating System? Operating System Definition

Chapter 2: System Structures

Introduction to Concurrency (Processes, Threads, Interrupts, etc.)

Module 1 Introduction/OS Overview

Operating System Structure

Kernel Types Simple OS Examples System Calls. Operating Systems. Autumn CS4023

Machines and Virtualization. Systems and Networks Jeff Chase Spring 2006

Operating System Review

Operating System Structure

Transcription:

Operating Systems Operating System Structure Lecture 2 Michael O Boyle 1

Overview Architecture impact User operating interaction User vs kernel Syscall Operating System structure Layers Examples 2

Lower-level architecture affects (is affected by) the OS The operating system supports sharing and protection multiple applications can run concurrently, sharing resources a buggy or malicious application cannot disrupt other applications or the system There are many approaches to achieving this The architecture determines which approaches are viable (reasonably efficient, or even possible) includes instruction set (synchronization, I/O, ) also hardware components like MMU or DMA controllers 3

Architecture support for the OS Architectural support can simplify OS tasks e.g.: early PC operating systems (DOS, MacOS) lacked support for virtual memory, in part because at that time PCs lacked necessary hardware support Until recently, Intel-based PCs still lacked support for 64-bit addressing has been available for a decade on other platforms: MIPS, Alpha, IBM, etc Changed driven by AMD s 64-bit architecture 4

Architectural features affecting OS s These features were built primarily to support OS s: timer (clock) operation synchronization instructions e.g., atomic test-and-set memory protection I/O control operations interrupts and exceptions protected modes of execution kernel vs. user mode privileged instructions system calls Including software interrupts virtualization architectures ASPLOS 5

Privileged instructions Some instructions are restricted to the OS known as privileged instructions Only the OS can: directly access I/O devices (disks, network cards) manipulate memory state management page table pointers, TLB loads, etc. manipulate special mode bits interrupt priority level Restrictions provide safety and security 6

OS protection So how does the processor know if a privileged instruction should be executed? the architecture must support at least two modes of operation: kernel mode and user mode x86 support 4 protection modes mode is set by status bit in a protected processor register user programs execute in user mode OS executes in kernel (privileged) mode (OS == kernel) Privileged instructions can only be executed in kernel (privileged) mode if code running in user mode attempts to execute a privileged instruction the Illegal excecutin trap 7

Crossing protection boundaries So how do user programs do something privileged? e.g., how can you write to a disk if you can t execute an I/O instructions? User programs must call an OS procedure that is ask the OS to do it for them OS defines a set of system calls User-mode program executes system call instruction Syscall instruction Like a protected procedure call 8

The syscall instruction atomically: Saves the current PC Syscall Sets the execution mode to privileged Sets the PC to a handler address Similar to a procedure call Caller puts arguments in a place callee expects (registers or stack) One of the args is a syscall number, indicating which OS function to invoke Callee (OS) saves caller s state (registers, other control state) so it can use the CPU OS function code runs OS must verify caller s arguments (e.g., pointers) OS returns using a special instruction Automatically sets PC to return address and sets execution mode to user 9

API System Call OS Relationship

A kernel crossing illustrated Firefox: read(int filedescriptor, void *buffer, int numbytes) user mode kernel mode Save user PC PC = trap handler address Enter kernel mode trap handler Save app state Verify syscall number Find sys_read( ) handler in vector table PC = saved PC Enter user mode sys_read( ) kernel routine Verify args Initiate read Choose next process to run Setup return values Restore app state ERET instruction http://syscalls.kernelgrok.com/ 11

Examples of Windows and Unix System Calls

System call issues A syscall is not subroutine call, with the caller specifying the next PC. the caller knows where the subroutines are located in memory; therefore they can be target of attack. The kernel saves state? Prevents overwriting of values The kernel verify arguments Prevents buggy code crashing system Referring to kernel objects as arguments Data copied between user buffer and kernel buffer 13

Exception Handling and Protection All entries to the OS occur via the mechanism just shown Acquiring privileged mode and branching to the trap handler are inseparable Terminology: Interrupt: asynchronous; caused by an external device Exception: synchronous; unexpected problem with instruction Trap: synchronous; intended transition to OS due to an instruction Privileged instructions and resources are the basis for most everything: memory protection, protected I/O, limiting user resource consumption, 14

Overview Architecture impact User operating interaction User vs kernel Syscall Operating System structure Layers Examples 15

OS structure The OS sits between application programs and the hardware it mediates access and abstracts away ugliness programs request services via traps or exceptions devices request attention via interrupts P1 dispatch trap or exception P2 OS P3 interrupt P4 D1 D2 D3 start i/o D4 16

Operating System Design and Implementation Design and Implementation of OS not solvable, but some approaches have proven successful Internal structure of different Operating Systems can vary widely Start the design by defining goals and specifications Affected by choice of hardware, type of system User goals and System goals User goals operating system should be convenient to use, easy to learn, reliable, safe, and fast System goals operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient

Operating System Design and Implementation Important principle to separate Policy: What will be done? Mechanism: How to do it? Mechanisms determine how to do something, policies decide what will be done The separation of policy from mechanism is a very important principle, it allows maximum flexibility if policy decisions are to be changed later (example timer) Specifying and designing an OS is highly creative task of software engineering

System layers User Apps Operating System Firefox File Systems Device Drivers Photoshop Application Interface (API) Memory Manager Interrupt Handlers Acrobat Process Manager Hardware Abstraction Layer Hardware (CPU, devices) Java Network Support Boot & Init Portable 19

Major OS components processes memory I/O secondary storage file systems protection shells (command interpreter, or OS UI) GUI Networking 20

OS structure It s not always clear how to stitch OS modules together: Command Interpreter Information Services Error Handling Protection System File System Accounting System Process Management Memory Management Secondary Storage Management I/O System 21

OS structure An OS consists of all of these components, plus: many other components system programs (privileged and non-privileged) e.g., bootstrap code, the init program, Major issue: how do we organize all this? what are all of the code modules, and where do they exist? how do they cooperate? Massive software engineering and design problem design a large, complex program that: performs well, is reliable, is extensible, is backwards compatible, 22

Early structure: Monolithic Traditionally, OS s (like UNIX) were built as a monolithic entity: user programs OS everything hardware

Monolithic design Major advantage: cost of module interactions is low (procedure call) Disadvantages: hard to understand hard to modify unreliable (no isolation between system modules) hard to maintain What is the alternative? find a way to organize the OS in order to simplify its design and implementation 24

Layering The traditional approach is layering implement OS as a set of layers each layer presents an enhanced virtual machine to the layer above The first description of this approach was Dijkstra s THE system Layer 5: Job Managers Execute users programs Layer 4: Device Managers Handle devices and provide buffering Layer 3: Console Manager Implements virtual consoles Layer 2: Page Manager Implements virtual memories for each process Layer 1: Kernel Implements a virtual processor for each process Layer 0: Hardware Each layer can be tested and verified independently 25

Problems with layering Imposes hierarchical structure but real systems are more complex: file system requires VM services (buffers) VM would like to use files for its backing store strict layering isn t flexible enough Poor performance each layer crossing has overhead associated with it Disjunction between model and reality systems modeled as layers, but not really built that way 26

Hardware Abstraction Layer An example of layering in modern operating systems Goal: separates hardware-specific routines from the core OS Provides portability Improves readability Core OS (file system, scheduler, system calls) Hardware Abstraction Layer (device drivers, assembly routines) 27

Microkernels Popular in the late 80 s, early 90 s recent resurgence of popularity Goal: minimize what goes in kernel organize rest of OS as user-level processes This results in: better reliability (isolation between components) ease of extension and customization poor performance (user/kernel boundary crossings) First microkernel system was Hydra (CMU, 1970) Follow-ons: Mach (CMU), Chorus (French UNIX-like OS), OS X (Apple), in some ways NT (Microsoft) 28

Microkernel structure illustrated user processes system processes firefox powerpoint itunes apache word file system network threads scheduling photoshop paging user mode microkernel low-level VM communication protection processor control Kernel mode hardware 29

Monolithic 30

31

Loadable Kernel Modules Kernel modules Kernel (Perhaps) the best practice for OS design Core services in the kernel and others dynamically loaded Common in modern implementations Solaris, Linux, etc. Advantages convenient: no need for rebooting for newly added modules efficient: no need for message passing unlike microkernel flexible: any module can call any other module unlike layered model 32

Summary Fundamental distinction between user and priviliged mode supported by most hardware OS design has been an evolutionary process of trial and error. Probably more error than success Successful OS designs have run the spectrum from monolithic, to layered, to micro kernels The role and design of an OS are still evolving It is impossible to pick one correct way to structure an OS 33