Architecture Support for OS CSCI 444/544 Operating Systems Fall 2008.

Slides:



Advertisements
Similar presentations
Computer-System Structures Er.Harsimran Singh
Advertisements

Threads, SMP, and Microkernels
OS Components and Structure
Threads, SMP, and Microkernels Chapter 4. Process Resource ownership - process is allocated a virtual address space to hold the process image Scheduling/execution-
1 OS Structure, Processes & Process Management. 2 Recap OS functions  Coordinator  Protection  Communication  Resource management  Service provider.
CS 153 Design of Operating Systems Spring 2015 Lecture 3: Intro and Architectural Support for Operating Systems.
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
1 CSE451 Operating Systems Winter 2009 Module 2 Architectural Support Mark Zbikowski Gary Kimura.
Operating System Structure. Announcements Make sure you are registered for CS 415 First CS 415 project is up –Initial design documents due next Friday,
OS Spring’03 Introduction Operating Systems Spring 2003.
1/28/2004CSCI 315 Operating Systems Design1 Operating System Structures & Processes Notice: The slides for this lecture have been largely based on those.
Figure 1.1 Interaction between applications and the operating system.
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
OS Spring’04 Introduction Operating Systems Spring 2004.
1 OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
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.
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
Protection and the Kernel: Mode, Space, and Context.
Chapter 1. Introduction What is an Operating System? Mainframe Systems
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
Processes and Threads Processes have two characteristics: – Resource ownership - process includes a virtual address space to hold the process image – Scheduling/execution.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 7 OS System Structure.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: Operating-System Structures.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Operating Systems Lecture November 2015© Copyright Virtual University of Pakistan 2 Agenda for Today Review of previous lecture Hardware (I/O, memory,
Processes Introduction to Operating Systems: Module 3.
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
Lecture Topics: 10/29 Architectural support for operating systems –timers –kernel mode –system calls –protected instructions.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
A. Frank - P. Weisberg Operating Systems Structure of Operating Systems.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 2: Computer-System Structures Computer System Architecture and Operation.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
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.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
OSes: 2. Structs 1 Operating Systems v Objective –to give a (selective) overview of computer system architectures Certificate Program in Software Development.
CENG334 Introduction to Operating Systems 1 Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY URL:
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
CSCE451/851 Introduction to Operating Systems
Introduction to Operating Systems Concepts
Computer System Structures
Kernel Design & Implementation
CSE451 Operating Systems Winter 2011
CSE 120 Principles of Operating
CSE 451: Operating Systems Spring 2006 Module 2 Architectural Support for Operating Systems John Zahorjan 534 Allen Center.
Module 2: Computer-System Structures
CSE 451: Operating Systems Winter 2006 Module 2 Architectural Support for Operating Systems Ed Lazowska 570 Allen Center 1.
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Architectural Support for OS
Operating Systems Lecture 3.
CSE 451: Operating Systems Autumn 2004 Module 2 Architectural Support for Operating Systems Hank Levy 1.
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
Module 2: Computer-System Structures
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
CSE 451: Operating Systems Spring 2005 Module 2 Architectural Support for Operating Systems Ed Lazowska 570 Allen Center 1.
OS Components and Structure
CSE 451: Operating Systems Winter 2007 Module 2 Architectural Support for Operating Systems Brian Bershad 562 Allen Center 1.
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Architectural Support for OS
CSE 451: Operating Systems Winter 2004 Module 2 Architectural Support for Operating Systems Ed Lazowska 570 Allen Center 1.
Module 2: Computer-System Structures
Steve Gribble (for Hank Levy)
Module 2: Computer-System Structures
Operating Systems Structure
Presentation transcript:

Architecture Support for OS CSCI 444/544 Operating Systems Fall 2008

Agenda Hardware Review - various components CPU, memory, disk - hardware support modes, memory protection, and interrupts OS Structure Monolithic approach Layered approach Microkernel approach Kernel modules Virtual machine

A Simple PC

CPU 1.Fetch unit 2.Decode unit 3.Execute unit Three-stage pipeline

Memory Hierarchy

Structure of a Disk Drive

Bus Structure of a large Pentium system

Architectural Support for OS These features were built primarily to support OS Modes of execution (OS protection) Memory protection Interrupts and exceptions I/O control operations Timer (clock) operation

Modes of Execution OS code is stored in memory What if a user program modifies OS code or data? Introduce modes of execution Instructions can be executed in user mode or kernel (system) mode A special register holds which mode the CPU is in Certain instructions can only be executed when in kernel mode Likewise, certain memory locations can only be written when in kernel mode Only OS code is executed in kernel mode Only OS can modify its memory The mode register can only be modified in kernel mode

Memory Protection OS must protect user programs from each other maliciousness, ineptitude Simplest scheme: base and limit registers base and limit registers are loaded by OS before starting program Paging, segmentation, virtual memory page tables, page table pointers translation lookaside buffers (TLBs) page fault handling

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 I/O instructions? User programs must call an OS procedure OS defines a sequence of system calls how does the user-mode to kernel-mode transition happen? There must be a system call instruction, which: throws a software interrupt, which vectors to a kernel handler passes a parameter indicating which system call to invoke saves caller’s state (regs, mode bit) so they can be restored OS must verify caller’s parameters (e.g., pointers) must be a way to return to user mode once done

Traps A trap is a special instruction that forces the PC to a known address and sets the mode into kernel Foundation of the system call

OS Control Flow After the OS has booted, all entry to the kernel happens as the result of an event event immediately stops current execution changes mode to kernel mode, event handler is called Kernel defines handlers for each event type specific types are defined by the architecture –e.g.: timer event, I/O interrupt, system call trap when the processor receives an event of a given type, it –transfers control to handler within the OS –handler saves program state (PC, regs, etc.) –handler functionality is invoked –handler restores program state, returns to program

Interrupts and Exceptions Two main types of events: interrupts and exceptions Exceptions are caused by software executing instructions –e.g., the x86 ‘int’ instruction –e.g., a page fault, or an attempted write to a read- only page –an expected exception is a “trap”, unexpected is a “fault” Interrupts are caused by hardware devices –e.g., device finishes I/O –e.g., timer fires

I/O Control Issues: how does the kernel start an I/O? –special I/O instructions –memory-mapped I/O how does the kernel notice an I/O has finished? –Polling (synchronous) –Interrupts (asynchronous) Interrupts are basis for asynchronous I/O device performs an operation asynchronously to CPU device sends an interrupt signal on bus when done in memory, a vector table contains list of addresses of kernel routines to handle various interrupt types CPU switches to address indicated by vector index specified by interrupt signal

Timers How can the OS prevent runaway user programs from hogging the CPU (infinite loops?) use a hardware timer that generates a periodic interrupt before it transfers to a user program, the OS loads the timer with a time to interrupt –“quantum” – how big should it be set? when timer fires, an interrupt transfers control back to OS –at which point OS must decide which program to schedule next Should the timer be privileged? for reading or for writing?

Monolithic Kernels Traditionally, OS’s are built as a monolithic entity: Single linked binary Any function can call any other function All in one place with no protection between components everything user programs hardware kernel

Monolithic Design Many modern OSes fall into this category: Unix, Windows XP Major advantage: Good performance, easy for kernel developers, well-understood, high- level of protection between applications Disadvantages: No isolation between kernel components Not (safely and easily) extensible As system scales, it becomes –Hard to modify –Hard to maintain What is the alternative? Find a way to organize the OS in order to simplify its design and implementation

Layered approach Idea: Implement OS as a set of layers The first description of this approach was Dijkstra’s THE system (1968!) 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

Problems with Layering Strict hierarchical structure is too inflexible Real systems have “uses” cycles –File system requires virtual memory services (buffers) –Virtual memory would like to use files for its backing store Poor performance Each layer crossing has overhead associated with it Virtual Memory File System

Microkernels Design Philosophy: protected kernel code provides minimal “small, clean, logical” set of abstractions processor control, virtual memory communication protection Organize the rest of OS as user-level processes –e.g., file system “server” Processes communicate using message-passing –Like a distributed system Examples: Mach, Chorus, QNX

Microkernels: Pros vs Cons Advantages Simplicity –Core kernel is very small Extensibility –Can add new functionality in user-mode code Reliability –OS services confined to user-mode programs Disadvantages Poor performance –Message transfer operations instead of system call

State of the Art: Kernel Modules Basic idea: users can supply modules, which run directly in the kernel’s address space Advantages: Good performance Extensibility Disadvantages: Modules can compromise security, reliability –Device drivers cause 85% of crashes in Windows 2000!

Solaries Loadable Modules Similar to a layered system, but more flexible Like the microkernel approach, but more efficient

Virtual Machine Abstract the hardware of a single computer into several different execution environments

System Boot Small piece of code – bootstrap loader, locates the kernel, loads it into memory, and starts it Quite often two-step process where a simple bootstrap loader at fixed location loads boot block, which in turn loads the kernel When power initialized on system, execution starts at a fixed memory location –Firmware used to hold initial boot code