OS Overview & Structure CSE 410 Winter 2017

Slides:



Advertisements
Similar presentations
Threads, SMP, and Microkernels
Advertisements

OS Components and Structure
WHAT IS AN OPERATING SYSTEM? An interface between users and hardware - an environment "architecture ” Allows convenient usage; hides the tedious stuff.
Operating Systems High Level View Chapter 1,2. Who is the User? End Users Application Programmers System Programmers Administrators.
1 CSE451 Introduction to Operating Systems Spring 2007 Module 3 Components and Structure Gary Kimura & Mark Zbikowski March 30, 2007.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
OS Spring’03 Introduction Operating Systems Spring 2003.
Cs238 Lecture 3 Operating System Structures Dr. Alan R. Davis.
Common System Components
1 Gary Kimura Lecture #3 October 4, 2002 CSE451 Operating Systems Components and Basic Organization Autumn 2002.
CSE 451: Operating Systems Spring 2012 Module 3 Operating System Components and Structure Ed Lazowska Allen Center 570 © 2012.
Stack Management Each process/thread has two stacks  Kernel stack  User stack Stack pointer changes when exiting/entering the kernel Q: Why is this necessary?
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
IT 344: Operating Systems Winter 2010 Module 3 Operating System Components and Structure Chia-Chi Teng 265G CTB 1.
OS provide a user-friendly environment and manage resources of the computer system. Operating systems manage: –Processes –Memory –Storage –I/O subsystem.
Architecture Support for OS CSCI 444/544 Operating Systems Fall 2008.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Operating Systems Lecture November 2015© Copyright Virtual University of Pakistan 2 Agenda for Today Review of previous lecture Hardware (I/O, memory,
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Overview of today’s lecture Major components of an operating system Structure and internal architecture of an operating system Monolithic Vs Micro-kernels.
Introduction to Operating Systems Concepts
Computer System Structures
Virtual Machine Monitors
Module 3: Operating-System Structures
Kernel Design & Implementation
Processes and threads.
Protection and OS Structure
CS 6560: Operating Systems Design
Chapter 1: Introduction
Operating System Structure
Introduction to Operating System (OS)
Operating Systems and Systems Programming
Chapter 2: System Structures
Chapter 3: Operating-System Structures
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
CSE 451: Operating Systems Autumn 2004 Module 3 Operating System Components and Structure Hank Levy 1.
CSE451 Operating Systems Winter 2010
Basic Concepts Protection: Security:
Lecture Topics: 11/1 General Operating System Concepts Processes
Architectural Support for OS
CSE 451: Operating Systems Winter 2007 Module 3 Operating System Components and Structure Ed Lazowska Allen Center
Hank Levy (for Hank Levy :)
CSE 451: Operating Systems Winter 2003 Lecture 1 Course Introduction
Chapter 2: Operating-System Structures
Operating Systems Lecture 3.
Introduction to Operating Systems
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
CSE 451: Operating Systems Autumn Module 24 Virtual Machine Monitors
CSE 451: Operating Systems Autumn 2009 Module 3 Operating System Components and Structure Ed Lazowska Allen Center
OS Components and Structure
CSE 451: Operating Systems Spring 2005 Module 3 Operating System Components and Structure Ed Lazowska Allen Center
CSE 451: Operating Systems Winter 2007 Module 2 Architectural Support for Operating Systems Brian Bershad 562 Allen Center 1.
CSE 451: Operating Systems Winter 2004 Module 3 Operating System Components and Structure Ed Lazowska Allen Center
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
© 2007 Gribble, Lazowska, Levy, Zahorjan
Architectural Support for OS
CSE 451: Operating Systems Winter 2003 Lecture 3 Operating System Structure: Components and Interfaces Hank Levy 412 Sieg Hall.
System calls….. C-program->POSIX call
CSE 451: Operating Systems Autumn 2010 Module 3 Operating System Components and Structure Ed Lazowska Allen Center
CSE 451: Operating Systems Autumn 2003 Lecture 3 Operating System Structure: Components and Interfaces Hank Levy Allen Center 596.
CSE 451: Operating Systems Autumn 2003 Lecture 1 Course Introduction
Chapter 2: Operating-System Structures
Operating Systems Structure
CSE 451: Operating Systems Autumn Module 24 Virtual Machine Monitors
CSE 451: Operating Systems Winter 2006 Module 3 Operating System Components and Structure Ed Lazowska Allen Center
CSE 451: Operating Systems Spring 2006 Module 3 Operating System Components and Structure John Zahorjan Allen Center 534.
Presentation transcript:

OS Overview & Structure CSE 410 Winter 2017 Slides adapted from CSE451 material by Gribble, Lazowska, Levy, and Zahorjan Instructor: Teaching Assistants: Justin Hsia Kathryn Chan, Kevin Bi, Ryan Wong, Waylon Huang, Xinyu Sui Internet of Things Teddy Bear Leaked 2 Million Parent and Kids Message Recordings Spiral Toys left customer data of its CloudPets brand on a database that wasn't behind a firewall or password-protected. As we've seen time and time again in the last couple of years, so-called "smart" devices connected to the internet—what is popularly known as the Internet of Things or IoT—are often left insecure or are easily hackable, and often leak sensitive data. After this story was published, a security researcher revealed that the stuffed animals themselves could easily be hacked and turned into spy devices. https://motherboard.vice.com/en_us/article/internet-of-things-teddy-bear-leaked-2- million-parent-and-kids-message-recordings

Quick Virtual Memory Review 11/23/2016 Quick Virtual Memory Review What do Page Tables map? Where are Page Tables located? How many Page Tables are there? Can your program tell if a page fault has occurred? True / False: Virtual Addresses that are contiguous will always be contiguous in physical memory TLB stands for _______________________ and stores _______________

Administrivia Lab 4 due Tuesday (3/7) Homework 5 due Thursday (3/9) Course evaluations now open https://uw.iasystem.org/survey/172382 Final Exam: Tue, Mar. 14 @ 2:30pm in MGH 241 Review Session: Sun, Mar. 12 @ 1:30pm in SAV 264 Cumulative (midterm clobber policy applies) TWO double-sided handwritten 8.5×11” cheat sheets Recommended that you reuse/remake your midterm cheat sheet

What is an Operating System? Answers: “I don't know” – Ed Lazowska, longtime OS researcher Nobody knows The book has some ideas – see Section 1.7 They’re programs – big, hairy programs The Linux source has over 1.7 million lines of C code Okay. Then what are some goals of an OS?

The Traditional Picture Applications OS Hardware “The OS is everything you don’t need to write in order to run your application” This depiction invites you to think of the OS as a library In some ways, it is: All operations on I/O devices require OS calls (syscalls) In other ways, it isn't: You use the CPU/memory without OS calls It intervenes without having been explicitly called

The OS and Hardware An OS mediates programs’ access to hardware resources (sharing and protection) Computation (CPU) Volatile storage (memory) and persistent storage (disk) Network communications (TCP/IP stacks, Ethernet cards) Input/output devices (keyboard, display, sound card) The OS abstracts hardware into logical resources and well-defined interfaces to those resources (ease of use) Processes (CPU, memory) Files (disk) Programs (sequences of instructions) Sockets (network)

Application Benefits of an OS Programming simplicity Can deal with high-level abstractions (files) instead of low-level hardware details (device registers) Abstractions are reusable across many programs Portability (across machine configurations or architectures) Device independence: 3com card or Intel card?

User Benefits of an OS Safety Efficiency (cost and speed) Gives each process the illusion of its own virtual machine Protects programs from each other “Fairly” multiplexes resources across programs Efficiency (cost and speed) Share one computer across many users Allows for concurrent execution of multiple programs

The Major OS Issues Structure: How is the OS organized? Sharing: How are resources shared across users? Naming: How are resources named? Security: How is the integrity of the OS and its resources ensured? Protection: How is one user/program protected from another? Performance: How do we make it all go fast? Reliability: What happens if something goes wrong (with hardware or with a program)? Extensibility: Can we add new features? Communication: How do programs exchange information, including across a network?

There are tradeoffs, not right and wrong! More OS Issues… Concurrency: How are parallel activities (computation and I/O) created and controlled? Scale: What happens as demands or resources increase? Persistence: How do you make data last longer than program executions? Distribution: How do multiple computers interact with each other? Accounting: How do we keep track of resource usage, and perhaps charge for it? There are tradeoffs, not right and wrong!

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) Privileged instructions System calls (and software interrupts) Virtualization architectures

Privileged instructions Privileged instructions can only be executed by the OS 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 The architecture must support at least two modes of operation: kernel mode and user mode Mode is set by status bit in a protected processor register User programs must call an OS procedure to do something privileged system calls User programs execute in user mode; OS executes in kernel mode. What happens if code running in user mode attempts to execute a privileged instruction?

System Calls syscall instruction atomically: # open is syscall 2 mov $0x2,%eax syscall # return value in %rax cmp $-4095,%rax syscall instruction atomically: Saves the current PC Sets the execution mode to privileged Sets the PC (%rip) to a handler address It’s a lot like a protected procedure call Caller puts arguments in a place callee expects One of the arguments is the syscall number Callee (OS) saves caller’s state (registers, other control state) so it can use the CPU OS must verify caller’s arguments, then runs handler code OS returns using a special instruction Also sets execution mode to user sysret

A Kernel Crossing Illustrated Chrome: read(int fileDescriptor, void *buffer, int numBytes) Save user PC PC = trap handler address Enter kernel mode user mode kernel mode PC = saved PC Enter user mode trap handler Save process state Verify syscall number Find sys_read() handler in vector table sys_read() kernel routine Verify arguments Initiate read Choose next process to run Setup return values Restore app state sysret instruction

OS Structure The OS sits between application programs (P for processes) and the hardware (D for devices) It mediates access and abstracts away ugliness Programs request services via traps or exceptions Devices request attention via interrupts OS P1 P2 P3 P4 D1 D2 D3 D4 trap or exception interrupt dispatch start i/o

Major OS Components Processes Memory Input/Output Secondary Storage (Disk) File Systems Protection Shells (command interpreter, or OS UI) GUI Networking Next several slides give an overview of each of these – don’t linger on this list on this slide

The Classic Diagram Chrome Powerpoint Slack Acrobat User Apps Chrome Powerpoint Slack Acrobat Portable Application Interface (API) Operating System File Systems Memory Manager Process Manager Network Support Device Drivers Interrupt Handlers Boot & Init Hardware Abstraction Layer Hardware (CPU, devices)

But reality isn’t always that simple… Command Interpreter Information Services Accounting System Error Handling File System Protection System Memory Management Secondary Storage Management Process Management I/O System

code, stack PC, registers Process management An OS executes many kinds of processes: Users’ programs Batch jobs or scripts System programs Print spoolers, name servers, file servers, network daemons, … Process includes the execution context PC, registers, VM, OS resources (e.g. open files), etc… The program itself (code and data) The OS’s process module manages these processes Process A: code, stack PC, registers page tables resources

States of a User Process trap or exception interrupt dispatch Running Ready Blocked Finished (“Zombie”) terminate Dispatch is the most important and involves tricky scheduling!

Process Module Operations The OS provides the following kinds operations on processes (i.e. the process abstraction interface): Create a process Delete a process Suspend a process Resume a process Clone a process Inter-process communication Inter-process synchronization Create/delete a child process

Memory Management Main (primary) memory is directly accessed by CPU Programs must be stored in memory to execute But memory doesn’t survive power failures The OS must: Allocate memory space for programs (explicitly & implicitly) De-allocate space when needed by rest of system Maintain physical to virtual memory mappings Decide how much memory to allocate to each process Decide when to remove a process from memory sbrk! loading! page faults! page tables! reaping a process! policy decisions

Input/Output A big chunk of the OS kernel deals with I/O The OS provides a standard interface between programs and devices e.g. file system (disk), sockets (network), frame buffer (video) Device drivers are the routines that interact with specific device types (encapsulate device-specific knowledge) How to initialize a device, request I/O, handle interrupts or errors, etc. Examples: SCSI device drivers, Ethernet card drivers, video card drivers, sound card drivers Note: Windows has ~35,000 device drivers that take up hundreds of thousands of lines of code!

Secondary Storage Secondary storage (disk, SSD) is persistent memory Often magnetic media, survives power failures (hopefully) Routines that interact with disks are typically at a very low level in the OS Used by many components (file system, VM, …) Handle scheduling of disk operations, head movement, error handling, and often management of space on disks Usually independent of file system Although there may be cooperation File system knowledge of device details can help optimize performance e.g. place related files close together on disk

File Systems Secondary storage devices are crude and awkward A file system is a convenient abstraction Defines logical objects like files and directories to hide details Defines operations on objects like read and write A file is the basic unit of long-term storage A file = a named collection of persistent information A directory is just a special kind of file A directory = named file that contains names of other files and metadata about those files (e.g. file size) Note: Sequential byte stream is only one possibility!

File System Operations The file system interface defines standard operations: File/directory creation, copy, and deletion File/directory manipulation (e.g. read, write, extend, rename, protect, lock) File systems also provide higher level services Accounting and quotas Backup (must be incremental and online!) (Sometimes) indexing or search (Sometimes) file versioning

Protection Protection mechanisms used throughout the OS help to detect and contain unintentional errors, as well as preventing malicious destruction All resources need to be protected: Memory Processes Files Devices CPU time Etc.

Command Interpreter (shell) A particular program that handles the interpretation of users’ commands and helps to manage processes User input may be from keyboard (command-line interface), from script files, or from the mouse (GUIs) Allows users to launch and control new programs On some systems, command interpreter may be a standard part of the OS Mostly for old/historical or tiny systems On others, it’s just non-privileged code that provides an interface to the user e.g. bash/csh/tcsh/zsh on UNIX

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

OS Structure An OS consists of all of these components, plus: Many more! System programs (privileged and non-privileged) e.g. bootstrap code, the init/systemd program, … Major issues: What are all of the code modules, and where do they exist? How do they cooperate? Massive software engineering and design problem Must design a large, complex program that performs well, is reliable, is extensible, is backwards compatible, …

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

Monolithic design Major advantage: Disadvantages: Cost of module interactions is low (procedure call) Disadvantages: Hard to understand, modify, and maintain Unreliable (no isolation between system modules) What is the alternative? Find a way to organize the OS in order to simplify its design and implementation

Layering Implement OS as a set of layers Example layering approach: Layers can only invoke functions in lower layers More organized and modular Each layer can be tested and verified independently! Example layering approach: Layer 6: Operator Layer 5: Job Managers Execute users’ programs Layer 4: I/O Management Handle devices and provide buffering Layer 3: Console Manager Implements virtual consoles Layer 2: Page Manager Memory management Layer 1: Kernel CPU scheduling and semaphores Layer 0: Hardware THE – "Technische Hogeschool Eindhoven,“ then the name of the Eindhoven University of Technology of the Netherlands.

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

Hardware Abstraction Layer An example of layering in modern operating systems Goal: Separate 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)

Microkernels Goal: Minimize what goes in the kernel Advantages: Organize the rest of the OS as user-level processes Advantages: Better reliability (isolation between components) Ease of extension and customization Disadvantages: Poor performance (user/kernel boundary crossings)

Microkernel Structure Illustrated User mode user processes powerpoint chrome photoshop apache spotify word file system network system processes paging threads scheduling Kernel mode communication processor control microkernel low-level VM protection hardware

Summary 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, to virtual machine monitors The role and design of an OS are still evolving It is impossible to pick one “correct” way to structure an OS – it’s all about design trade-offs