Operating Systems CS451

Operating Systems CS451

Systems Spring 2012 Module 3 Operating System Components and Structure Ed Lazowska lazowska @cs.washi ngton.edu Allen Center 570 2012 Gribble, Lazowska, Levy, Zahorjan 1 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 P2 P3 P4 P1 dispatch trap or exception OS interrupt D1 start i/o D2

D3 2012 Gribble, Lazowska, Levy, Zahorjan D4 2 User Apps Firefox Photoshop Java Application Interface (API) Memory Manager Device Drivers

Process Manager Interrupt Handlers Network Support Portable File Systems Operating System Acrobat Boot & Init

Hardware Abstraction Layer Hardware (CPU, devices) 2012 Gribble, Lazowska, Levy, Zahorjan 3 Command Interpreter Information Services Error Handling File System Accounting System Protection System Process Management Memory Management Secondary Storage

Management I/O System 2012 Gribble, Lazowska, Levy, Zahorjan 4 Major OS components processes memory I/O secondary storage

file systems protection shells (command interpreter, or OS UI) GUI networking 2012 Gribble, Lazowska, Levy, Zahorjan 5 Process management An OS executes many kinds of activities: users programs batch jobs or scripts system programs print spoolers, name servers, file servers, network daemons, Each of these activities is encapsulated in a process a process includes the execution context PC, registers, VM, OS resources (e.g., open files), etc plus the program itself (code and data)

the OSs process module manages these processes creation, destruction, scheduling, 2012 Gribble, Lazowska, Levy, Zahorjan 6 Program/processor/process Note that a program is totally passive just bytes on a disk that encode instructions to be run A process is an instance of a program being executed by a (real or virtual) processor at any instant, there may be many processes running copies of the same program (e.g., an editor); each process is separate and (usually) independent Linux: ps -auwwx to list all processes process B process A code stack

PC registers page tables resources code stack PC registers 2012 Gribble, Lazowska, Levy, Zahorjan page tables resources 7 States of a user process running

dispatch interrupt ready trap or exception interrupt blocked 2012 Gribble, Lazowska, Levy, Zahorjan 8 Process 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 (subprocess) 2012 Gribble, Lazowska, Levy, Zahorjan 9 Memory management

The primary memory is the directly accessed storage for the CPU programs must be stored in memory to execute memory access is fast but memory doesnt survive power failures OS must: allocate memory space for programs (explicitly and implicitly) deallocate space when needed by rest of system maintain mappings from physical to virtual memory through page tables decide how much memory to allocate to each process a policy decision decide when to remove a process from memory also policy 2012 Gribble, Lazowska, Levy, Zahorjan 10

I/O A big chunk of the OS kernel deals with I/O hundreds of thousands of lines in NT The OS provides a standard interface between programs (user or system) and devices file system (disk), sockets (network), frame buffer (video) Device drivers are the routines that interact with specific device types encapsulates device-specific knowledge e.g., how to initialize a device, how to request I/O, how to handle interrupts or errors examples: SCSI device drivers, Ethernet card drivers, video card drivers, sound card drivers, Note: Windows has ~35,000 device drivers! 2012 Gribble, Lazowska, Levy, Zahorjan 11

Secondary storage Secondary storage (disk, tape) 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 2012 Gribble, Lazowska, Levy, Zahorjan 12 File systems Secondary storage devices are crude and awkward

e.g., write 4096 byte block to sector 12 File system: a convenient abstraction defines logical objects like files and directories hides details about where on disk files live as well as operations on objects like read and write read/write byte ranges instead of blocks A file is the basic unit of long-term storage file = named collection of persistent information A directory is just a special kind of file 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! 2012 Gribble, Lazowska, Levy, Zahorjan 13 File system operations

The file system interface defines standard operations: file (or directory) creation and deletion manipulation of files and directories (read, write, extend, rename, protect) copy lock File systems also provide higher level services accounting and quotas backup (must be incremental and online!) (sometimes) indexing or search (sometimes) file versioning 2012 Gribble, Lazowska, Levy, Zahorjan 14

Protection Protection is a general mechanism used throughout the OS all resources needed to be protected memory processes files devices CPU time protection mechanisms help to detect and contain unintentional errors, as well as preventing malicious destruction

2012 Gribble, Lazowska, Levy, Zahorjan 15 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 (e.g., MS DOS, Apple II) On others, its just non-privileged code that provides an interface to the user e.g., bash/csh/tcsh/zsh on UNIX On others, there may be no command language e.g., MacOS 2012 Gribble, Lazowska, Levy, Zahorjan

16 OS structure Its not always clear how to stitch OS modules together: Command Interpreter Information Services Error Handling File System Accounting System Protection System Process Management Memory Management Secondary Storage Management

I/O System 2012 Gribble, Lazowska, Levy, Zahorjan 17 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,

2012 Gribble, Lazowska, Levy, Zahorjan 18 2012 Gribble, Lazowska, Levy, Zahorjan 19 Early structure: Monolithic Traditionally, OSs (like UNIX) were built as a monolithic entity: user programs OS everything hardware 2012 Gribble, Lazowska, Levy, Zahorjan

20 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 2012 Gribble, Lazowska, Levy, Zahorjan

21 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 Dijkstras 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 2012 Gribble, Lazowska, Levy, Zahorjan 22 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 isnt 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

2012 Gribble, Lazowska, Levy, Zahorjan 23 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)

2012 Gribble, Lazowska, Levy, Zahorjan 24 Microkernels Popular in the late 80s, early 90s 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) 2012 Gribble, Lazowska, Levy, Zahorjan

25 Microkernel structure illustrated powerpoint photoshop processor control word file system network threads scheduling communication microkernel

paging user mode system processes firefox apache itunes Kernel mode user processes low-level VM protection hardware

2012 Gribble, Lazowska, Levy, Zahorjan 26 From Andy Tanenbaum 27 From Andy Tanenbaum 28 Transparently implement hardware in software Voil, you can boot a guest OS From http://port25.technet.com/ 29 Summary and Next Module Summary OS design has been a 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 Next module Processes, one of the most fundamental pieces in an OS What is a process, what does it do, and how does it do it 2012 Gribble, Lazowska, Levy, Zahorjan 30

Recently Viewed Presentations

  • 1st Ohio Physician Assistant Student Conference

    1st Ohio Physician Assistant Student Conference

    1st Ohio Physician Assistant Student Conference. Presented by Lauren Wiley PA-S . Student Representative of OAPA. 1st OAPA Student Conference . Conference was held April 26-27, 2010 . At Columbus Airport Marriott . Cost: No fee for OAPA members ;...
  • Management of asymptomatic carotid stenosis

    Management of asymptomatic carotid stenosis

    Symptomatic Carotid artery stenosis. Carotid stenting (CAS) now available as alternative to CEA, multiple studies, meta-analysis shows that CAS is associated with increasing procedural stroke risk in a linear fashion with patient age. ... TCD assessment of MCA flow velocities...
  • The vestibular system Michael E. Goldberg, M.D. Please

    The vestibular system Michael E. Goldberg, M.D. Please

    In either case, the brain adjusts the VOR signal so the retinal slip is eliminated. The cerebellum is necessary for both suppression of the VOR and for slip-induced gain change. The horizontal vestibulo-ocular reflex (VOR) Vestibular Nystagmus The optokinetic signal...
  • 高性能健壮系统中的内存管理 - codingnow.com

    高性能健壮系统中的内存管理 - codingnow.com

    高性能健壮系统中的内存管理 合理的内存管理策略带来 系统性能的提高 更高的运行速度 更小的内存占用 稳定的内存使用量 让系统更健壮 减少因系统设计规模的扩大而带来的负作用 易于调试 减少编码失误率 控制 bug 的坏影响的范围 让系统可以长期不间断的工作 内存是最难管理的资源 内存作为一 ...
  • LIGHT - Fourth Grade News at Austin!

    LIGHT - Fourth Grade News at Austin!

    LIGHT. Energy is the ability to cause change. Light is a form of energy that you can see. Light and sound are forms of energy that travel in waves. Light waves travel in straight lines in every direction away from...
  • Queensland University of Technology Roles of assessment in

    Queensland University of Technology Roles of assessment in

    Talking your ear off Gym junkies Gifted hands Ah McCain you've done it again An analysis of alcohol induced loquaciousness Investigation into student internet usage Maritime museum usage pH of river Optical illusions Voluntary student unionism: to join or not...
  • Principles of Relative Dating: Laws of Stratigraphy [struh-tig-ruh-fee]

    Principles of Relative Dating: Laws of Stratigraphy [struh-tig-ruh-fee]

    I can describe the principles of relative dating and Laws of Stratigraphy. I know I am successful when I … Define and explain Laws of Stratigraphy: Law of Original Horizontality, Law of Superposition, Law of Lateral Continuity, Law of Cross-Cutting...
  • Power Tools

    Power Tools

    Bandsaw. Mortiser. Planer. Sanding machines. Lathes. Sanders. There are a few types of sander. ... In the event of an accident the earth wire directs the current to the ground through the electrical supply, possible preventing injury. Power supply.