Operating Systems. Operating Systems. Operating Systems. Operating Systems. If OS s Were Airlines. If OS s Were Airlines.



Similar documents
Networks and Operating Systems ( ) Chapter 1: Introduction to Operating Systems

Operating Systems 4 th Class

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

How do Users and Processes interact with the Operating System? Services for Processes. OS Structure with Services. Services for the OS Itself

Review from last time. CS 537 Lecture 3 OS Structure. OS structure. What you should learn from this lecture

Lesson Objectives. To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization

CSC 2405: Computer Systems II

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

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

Operating System Components

Operating Systems. Lecture 03. February 11, 2013

Introduction. What is an Operating System?

The PC Boot Process - Windows XP.

Example of Standard API

Operating System Structures

Operating System Overview. Otto J. Anshus

Chapter 2 System Structures

Chapter 6, The Operating System Machine Level

Chapter 3: Operating-System Structures. System Components Operating System Services System Calls System Programs System Structure Virtual Machines

CHAPTER 15: Operating Systems: An Overview

CS161: Operating Systems

Operating System Structures

Operating System Organization. Purpose of an OS

Chapter 3: Operating-System Structures. Common System Components

Linux Kernel Architecture

1. Computer System Structure and Components

Kernel Types System Calls. Operating Systems. Autumn 2013 CS4023

Operating system Dr. Shroouq J.

Operating Systems Overview

Chapter 3 Operating-System Structures

Multiprogramming. IT 3123 Hardware and Software Concepts. Program Dispatching. Multiprogramming. Program Dispatching. Program Dispatching

CPS221 Lecture: Operating System Structure; Virtual Machines

OPERATING SYSTEMS STRUCTURES

CSE 120 Principles of Operating Systems. Modules, Interfaces, Structure

Introduction to Operating Systems. Perspective of the Computer. System Software. Indiana University Chen Yu

How To Understand The History Of An Operating System

Outline: Operating Systems

Overview of Operating Systems Instructor: Dr. Tongping Liu

Operating System Fundamentals Robert Power & Robert Ford

Technology in Action. Alan Evans Kendall Martin Mary Anne Poatsy. Eleventh Edition. Copyright 2015 Pearson Education, Inc.

Chapter 11 I/O Management and Disk Scheduling

MICROPROCESSOR AND MICROCOMPUTER BASICS

Chapter 2: OS Overview

Operating System Software

Have both hardware and software. Want to hide the details from the programmer (user).

Operating System Structure

CS 3530 Operating Systems. L02 OS Intro Part 1 Dr. Ken Hoganson

Kernel. What is an Operating System? Systems Software and Application Software. The core of an OS is called kernel, which. Module 9: Operating Systems

Process Description and Control william stallings, maurizio pizzonia - sistemi operativi

COS 318: Operating Systems

Components of a Computer System

Chapter 1 Computer System Overview

Computer-System Architecture

System Structures. Services Interface Structure

Traditional IBM Mainframe Operating Principles

Lecture 1 Operating System Overview

OPERATING SYSTEM SERVICES

Introduction. System Calls

Chapter 16: Virtual Machines. Operating System Concepts 9 th Edition

Fastboot Techniques for x86 Architectures. Marcus Bortel Field Application Engineer QNX Software Systems

Operating System Components and Services

Chapter 2 Basic Structure of Computers. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

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

Operating Systems OS Architecture Models

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

OS Concepts and structure

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Devices and Device Controllers

CS420: Operating Systems OS Services & System Calls

ELEC 377. Operating Systems. Week 1 Class 3

Thomas Fahrig Senior Developer Hypervisor Team. Hypervisor Architecture Terminology Goals Basics Details

ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER

Software systems and issues

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

Operating Systems: Basic Concepts and History

The Plan Today... System Calls and API's Basics of OS design Virtual Machines

Central Processing Unit

Computers: Tools for an Information Age

How To Write A Windows Operating System (Windows) (For Linux) (Windows 2) (Programming) (Operating System) (Permanent) (Powerbook) (Unix) (Amd64) (Win2) (X

Operating Systems. Notice that, before you can run programs that you write in JavaScript, you need to jump through a few hoops first

LSN 10 Linux Overview

Chapter 3: Operating Systems

Operating Systems Prof. Ashok K Agrawala

Operating Systems Introduction

Chapter 4. System Software. What You Will Learn... Computers Are Your Future. System Software. What You Will Learn... Starting the Computer

Operating Systems. and Windows

Operating Systems. Rafael Ramirez (T, S)

Input / Output and I/O Strategies

TotalShredder USB. User s Guide

Chapter 1: Introduction. Chapter 1: Introduction. Operating System Concepts, 7th Edition. Objectives

SYSTEM ecos Embedded Configurable Operating System

Device Drivers: Their Function in an Operating System

Computer Organization

Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 412, University of Maryland. Guest lecturer: David Hovemeyer.

ThinLinX TLXOS 64-bit Firmware Installation Guide for the Intel NUC Range. Materials Required

Unit 4 Objectives. System Software. Component 4: Introduction to Information and Computer Science. Unit 4: Application and System Software Lecture 2

Operating System Tutorial

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-17: Memory organisation, and types of memory

Transcription:

Operating Systems Dickinson College Computer Science 354 Spring 2010 Operating Systems Professor Braught Email: braught@dickinson.edu Web: www.dickinson.edu/~braught Office:Tome 234 Office Hours: Monday 10:30-11:30 Wednesday 1:00-1:30 Thursday 9:00-10:00 Friday 11:00-11:50 Class Meetings: MTh 1:30-2:45 Tome 231 Operating Systems Syllabus: Silberschatz, Galvin, Gagne (2009). Operating Systems Concepts, Eighth Edition. Grading: Homework (7): 30% Projects (6): 25% Midterms (2): 20% Cumulative Final: 25% Cheating and Plagiarism Late Work Policy Operating Systems Course Outline: Joke What is an OS and why do we have them? Programs and Processes Process Scheduling Threads Thread Synchronization Memory Management File Systems If OS s Were Airlines Air Mac: All the stewards, captains, baggage handlers, and ticket agents look and act exactly the same. Every time you ask questions about details, you are gently but firmly told that you don't need to know, don't want to know, and everything will be done for you without your ever having to know, so just shut up. Air Windows: The terminal is pretty and colorful, with friendly stewards, easy baggage check and boarding, and a smooth take-off. After about 10 minutes in the air, the plane explodes with no warning whatsoever. If OS s Were Airlines Air Linux: Disgruntled employees of all the other OS airlines decide to start their own airline. They build the planes, ticket counters, and pave the runways themselves. They charge a small fee to cover the cost of printing the ticket, but you can also download and print the ticket yourself. When you board the plane, you are given a seat, four bolts, a wrench and a copy of the seat-howto.html. Once settled, the fully adjustable seat is very comfortable, the plane leaves and arrives on time without a single problem, the in-flight meal is wonderful. You try to tell customers of the other airlines about the great trip, but all they can say is, "You had to do what with the seat?" 1

Operating Systems What is an operating system? Why do we have operating systems? OS Purposes An operating system serves two main purposes: It makes the computer easier to use. Bridges the gap between the raw hardware and the user s experience. It allows for more efficient use of the computer hardware. Ease of Use User Perspective: OS make it easier for users to do things like: Launch programs Use multiple programs concurrently Keep track of files Add additional hardware devices Run really large programs Ease of Use Program / Programmer Perspective The OS makes it easier for programs (and programmers) to use the computer by providing support for common tasks: Accessing hardware devices Sharing system resources with other programs Coordinating activity with other programs As operating systems improve so does the user experience. Efficient use of Hardware Operating system advances that allow more efficient use of computer hardware: Task Switching Multiprogramming Timesharing Operating System Design An operating system will trade-off ease of use against efficient use of the hardware depending on the goals of the computer system for which it is designed. The use of these advances necessitate that the operating system also manage: Resource allocation and sharing Protection and Security 2

OS as a Bridge Key elements of user experience: Multiple concurrent programs Large memory Files and Directories Protection from other programs / users Communication / interaction with other programs / users User Interface / GUI Raw Hardware Assumptions Single CPU Machine Executes 1 instruction at a time Fetch / Decode / Execute Program Counter (PC): holds memory address for next fetch. Instruction Register (IR): holds instruction for decode/execute. Memory is array of bytes. Instruction execution is atomic. Programs store operands and results in general purpose registers. Process Context A Process Context includes: The register contents (GPRs and PC) Contents of its memory Files open for reading and writing etc By saving a process context it can be suspended and restarted later. Raw Hardware Assumptions Hard Disks: Basic hard disk controller can: Read a sector (or block) Write a sector (or block) Sector to read/write is specified by a cylinder:head:sector (CHS) address. Some disk controllers also use linear block addressing (LBA). Image from: Linux System Administrators Guide http://www.tldp.org/ldp/sag/html/hard-disk.html Raw Hardware Assumptions Basic Input/Output System (BIOS) Contains a number of small programs and subroutines: Power on self test (POST) System configuration utility Settings stored in small amount of battery backed CMOS memory. A set of routines for performing basic operations on common input/ output devices. Read / write a specified C:H:S from disk. Read character from keyboard. Display character on the screen. OS bootstrap program Stored on a Flash ROM that is part of the computer s address space. CMOS for configuration is also in address space. Bootstrap Process In the beginning there is only the BIOS. The PC is initialized to the address of the POST program contained in the BIOS The last instruction of the POST jumps to the address of the bootstrap program, also contained in the BIOS. The bootstrap program uses the BIOS routines to load a program contained in the Master Boot Record (MBR) of the boot disk into memory at a known address. MBR = first sector on the disk (512 bytes). Boot disk is identified by data stored in the configuration CMOS. The last instruction in the bootstrap program jumps to the address at which the MBR program was loaded. The MBR program loads the OS kernel. Often indirectly by loading another program (a secondary boot loader) that loads the kernel. 3

Random OS Quote Saying that [Microsoft Windows] XP is the most stable MS OS is like saying that asparagus is the most articulate vegetable. Dave Barry Hardware Support for OS Bridge All use of shared system resources must be controlled by the operating system if it is to provide: Protection Multiprogramming Timesharing Additional hardware is required to ensure that the operating system can control all use of shared resources. Hardware Support for OS The hardware support that is required is provided by: A mechanism for handling Interrupts A mechanism for making system calls Dual mode processor operation Base and limit registers A Timer hardware device Interrupts An interrupt is a signal from a device indicating that: An error has occurred. An event has occurred. Mouse has moved. Key has been pressed. An operation is complete. Data has been successfully written. Data is ready to be retrieved. Interrupt Handling When an interrupt occurs: PC is loaded with address the address of an Interrupt Service Routine (ISR), which is part of the BIOS or the Operating System. Typically: ISR asks OS to suspend the process that was executing. ISR processes the interrupt. Reads mouse action / fetches character from keyboard etc ISR asks the OS restart a process. Vectored Interrupts Modern systems use vectored interrupts. Each device is assigned an interrupt request number (IRQ). The device s IRQ is used as an index into the interrupt vector. The value at each index is the address of the ISR associated with the interrupt. The value from the interrupt vector is loaded into the PC. 4

Interrupts and Multiprogramming Interrupts enable multiprogramming via: Interrupt driven I/O Direct memory access (DMA) System Calls System calls are the mechanism by which a user processes requests resources and services that are controlled by the operating system. Conceptually, a system call is like a function call to a function that is part of the operating system. The mechanism is just a little different. System Calls When a process makes a system call, control is transfers to the operating system. Code in the operating system carries out the request and eventually control is returned to the process. System Call Mechanisms A process makes a system call by executing a special machine language instruction: SYSCALL TRAP INT CALL Usually you do not see the system call instruction because it is wrapped inside a language library (java / c,c++ / etc). User Process f = open( myfile.txt, RW ); fprintf(f, ABC ); close(f); System call Operating System User Process fprintf(f, ABC ); Function call Library fprintf() { SYSCALL 29; return; } System call OS System Call Mechanisms A system call causes control to automatically transfer to OS using the interrupt vector. Library fprintf() { SYSCALL 29; return; } Interrupt Vector Operating System 29 write() { OS code for writing to a file } System Call Mechanisms Parameters for a system call can be passed to the OS in three general ways: On the system stack In registers In a block of memory Different techniques are used for different system calls and even for individual parameters of the same system call. E.g. Writing to a file. The file to write is usually indicated by an integer passed in a register. The data to be written is passed using a pointer to block of memory (the pointer can be passed in a register). 5

Dual Mode Operation To provide protection, modern processors have two different modes of operation: User Mode Kernel Mode a.k.a. [System Supervisor System Privileged] Mode The processor mode is indicated by the mode bit in the processor status word (PSW). 0 = kernel mode 1 = user mode Kernel Mode All instructions that access shared resources are made to be privileged instructions. Privileged instructions may only be executed when the processor is in kernel mode. Any attempt to execute a privileged instruction in user mode results in an interrupt. The ISR in the OS will then terminate the offending process. Dual Mode, Interrupts and System Calls Every system call or interrupt automatically switches the processor to kernel mode before control transfers to the operating system code. The OS then switches the kernel back to user mode before returning control to a user process. Base and Limit Registers Base and Limit registers provide the simplest mechanism for protecting memory. Address generated during execution of Process A Base 2018 CPU 3562 yes < no Limit 3196 + no yes Memory Operating System Process A Process B 0 2018 5214 Interrupt Note: Assume CPU is executing Process A Free 9768 Timer Device Time sharing is enabled by the timer device. The timer is usually implemented using a fixed rate clock and a counter. The counter is set to a positive value. The value of the counter is then decremented on each tick of the clock. When the counter reaches 0 an interrupt is generated. Random OS Quote One of the main advantages of Unix over, say, MVS, is the tremendous number of features Unix lacks. Chris Torek 6

OS Responsibilities Operating systems are generally divided into several different sub-systems: Process Management Process = Running program Memory Management Storage Management Process Management Process management includes: Creating / Deleting processes Scheduling processes Blocking / Unblocking processes Interprocess communication mechanisms Synchronization mechanisms Memory Management Memory management is responsible for: Tracking used/free memory Allocating/deallocating memory Movement of processes to/from secondary storage i.e. Virtual Memory Storage Management Storage management is responsible for: Creating / deleting files Creating / deleting directories File / directory manipulation Read / write / change permissions Mapping files and directories onto disk Tracking free / used disk space. Implementing Operating Systems Some of the design decisions faced in implementing an operating system include: System software vs. OS kernel Separation of mechanism and policy Kernel architecture System Software vs. Kernel Many services can be implemented either in the OS kernel or as a processes that can be run in user mode. 7

Mechanism and Policy Policies are likely to change over time and thus should be separate from the mechanisms used to enforce them. An ideal mechanism is general enough to support a wide range of policies. Kernel Architecture There are roughly 4 major architecture alternatives for OS Kernel design: Monolithic (a.k.a. Simple) Structure Layered Structure Microkernel Structure Modular Structure Monolithic Kernels In a monolithic kernel nearly all OS functionality is contained in a single software module. the Big Mess. The structure is that there is no structure. Tannenbaum MS-DOS Kernel Application Programs MS-DOS Kernel Benefits? Drawbacks? MS-DOS Device Drivers Examples: MS-DOS Original UNIX BIOS Device Drivers Physical Hardware Original UNIX Kernel Layered Kernels Operating System Kernel User Applications and System Software Process Management Memory Management Device Management System Call Interface Device Drivers Physical Hardware Storage Management Protection Security OS is designed in layers such that: Each layer uses only the services provided by the next lower layer. The services provided by each layer are defined by a public interface.. Hardware 8

Micro-Kernels Modular Kernels With a micro-kernel only that functionality that actually requires kernel mode is included in the kernel. Basic process and memory management Message passing Keep kernel policy free. All other functionality is implemented as separate processes that execute in user mode. Storage Manager User Process micro-kernel Virtual Memory Modular kernels have a core set of capabilities (almost a micro-kernel) but then also allow other modules to be dynamically added to the kernel during boot or during execution. Virtual Machines VMWare Virtual machines provide a mechanism for hosting multiple independent operating systems on a single machine. The VMWare virtualization later runs as an application on a host operating system. This application appears to the guest operating system as if it is a complete machine with its own CPU, memory and I/O devices. Image from VMWare Whitepaper. Random OS Quote We just don't think a Linux partition on a mainframe makes a lot of sense. It's kind of like having a trailer park in the back of your estate. Scott McNealy 9