1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.

Slides:



Advertisements
Similar presentations
CSE 451: Operating Systems Winter 2014 Module 2 Architectural Support for Operating Systems Mark Zbikowski 476 Allen Center 1 ©
Advertisements

Chapter 6 Limited Direct Execution
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.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
1 CSE451 Operating Systems Winter 2009 Module 2 Architectural Support Mark Zbikowski Gary Kimura.
Operating System and Computer Organization Background CS 502 Spring 99 WPI MetroWest/Southboro Campus.
OS Spring’03 Introduction Operating Systems Spring 2003.
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
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.
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
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.
3/11/2002CSE Input/Output Input/Output Control Datapath Memory Processor Input Output Memory Input Output Network Control Datapath Processor.
Protection and the Kernel: Mode, Space, and Context.
IT 344: Operating Systems Winter 2008 Module 2 Operating Systems Overview Chia-Chi Teng 265G CTB.
Architecture Support for OS CSCI 444/544 Operating Systems Fall 2008.
1 CSE Department MAITSandeep Tayal Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
2: Computer-System Structures
Chapter 2: Computer-System Structures 2.1 Computer System Operation 2.5 Hardware Protection 2.6 Network Structure.
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
CS 153 Design of Operating Systems Spring 2015 Lecture 2: Intro and Architectural Support for Operating Systems.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
Lecture Topics: 10/29 Architectural support for operating systems –timers –kernel mode –system calls –protected instructions.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
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.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
OSes: 2. Structs 1 Operating Systems v Objective –to give a (selective) overview of computer system architectures Certificate Program in Software Development.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Chapter 6 Limited Direct Execution Chien-Chung Shen CIS/UD
Of Privilege, Traps, Interrupts & Exceptions Prof. Sirer CS 316 Cornell University.
Introduction to Operating Systems
Operating Systems CMPSC 473
Protection and OS Structure
CSE451 Operating Systems Winter 2012
Anton Burtsev February, 2017
CSE451 Operating Systems Winter 2011
CSE 120 Principles of Operating
CSE 451: Operating Systems Spring 2012 Module 2 Architectural Support for Operating Systems Ed Lazowska 570 Allen Center 1.
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.
CSE 153 Design of Operating Systems Winter 18
CSE 451: Operating Systems Winter 2007 Module 2 Architectural Support for Operating Systems Ed Lazowska 570 Allen Center 1.
Architectural Support for OS
CSE 451: Operating Systems Autumn 2004 Module 2 Architectural Support for Operating Systems Hank Levy 1.
CSE 451: Operating Systems Autumn 2010 Module 2 Architectural Support for Operating Systems Ed Lazowska 570 Allen Center 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.
CSE 451: Operating Systems Autumn 2009 Module 2 Architectural Support for Operating Systems Ed Lazowska 570 Allen Center 1.
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:

1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002

2 Today What hardware support does the OS use? But first, a word to non-CSE majors wanted to take the course

3 Architecture affects the OS Operating system functionality is dictated, at least in part, by the underlying hardware architecture –includes instruction set (synchronization, I/O, …) –also hardware components like MMU or DMA controllers Architectural support can vastly simplify (or complicate!) 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

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) –protected instructions –system calls (and software interrupts)

5 Protected Instructions some instructions are restricted to the OS –known as protected or privileged instructions e.g., only the OS can: –directly access I/O devices (disks, network cards) why? –manipulate memory state management page table pointers, TLB loads, etc. why? –manipulate special ‘mode bits’ interrupt priority level why? –halt instruction why?

6 OS Protection So how does the processor know if a protected instruction should be executed? –the architecture must support at least two modes of operation: kernel mode and user mode VAX, x86 support 4 protection modes why more than 2? –mode is set by status bit in a protected processor register user programs execute in user mode OS executes in kernel mode (OS == kernel) Protected instructions can only be executed in the kernel mode –what happens if user mode executes a protected instruction?

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 do 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: –causes an exception (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

8 A Kernel Crossing Illustrated user mode kernel mode Netscape: read( ) trap to kernel mode; save app state find read( ) handler in vector table restore app state, return to user mode, resume trap handler read( ) kernel routine

9 System Call Issues What would happen if kernel didn’t save state? Why must the kernel verify arguments? How can you reference kernel objects as arguments or results to/from system calls?

10 Memory Protection OS must protect user programs from each other –maliciousness, ineptitude OS must also protect itself from user programs –integrity and security –what about protecting user programs from OS? Simplest scheme: base and limit registers –are these protected? Prog A Prog B Prog C base reg limit reg base and limit registers are loaded by OS before starting program

11 More sophisticated memory protection coming later in the course virtual memory –paging, segmentation –page tables, page table pointers –translation lookaside buffers (TLBs)

12 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

13 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, 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

14 Exceptions Hardware must detect special conditions: page fault, write to a read-only page, overflow, trace trap, odd address trap, privileged instruction trap, syscall... Must transfer control to handler within the OS Hardware must save state on fault (PC, etc) so that the faulting process can be restarted afterwards Modern operating systems use VM traps for many functions: debugging, distributed VM, garbage collection, copy-on-write... Exceptions are a performance optimization, i.e., conditions could be detected by inserting extra instructions in the code (at high cost)

15 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 interrupts Interrupts are basis for asynchronous I/O –device performs an operation asynch 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 who populates the vector table, and when? –CPU switches to address indicated by vector specified by interrupt signal

device interrupts CPU stops current operation, switches to kernel mode, and saves current PC and other state on kernel stack CPU fetches proper vector from vector table and branches to that address (to routine to handle interrupt) interrupt routine examines device database and performs action required by interrupt handler completes operation, restores saved (interrupted state) and returns to user mode (or calls scheduler to switch to another program) I/O Control (continued)

17 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 very interesting policy question: we’ll dedicate a class to it Should the timer be privileged? –for reading or for writing?

18 Synchronization Interrupts cause a wrinkle: –may occur any time, causing code to execute that interferes with code that was interrupted –OS must be able to synchronize concurrent processes Synchronization: –guarantee that short instruction sequences (e.g., read-modify-write) execute atomically –one method: turn off interrupts before the sequence, execute it, then re-enable interrupts architecture must support disabling interrupts –another method: have special complex atomic instructions read-modify-write test-and-set load-linked store-conditional

19 Next Time We now know what the hardware gives us to use, so How do we conceptually organize an OS to put it all together?