OS-Unit I -part 1-Thomas sir

download OS-Unit I -part 1-Thomas sir

of 30

Transcript of OS-Unit I -part 1-Thomas sir

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    1/30

    Unit I: Fundamentals (part1)Unit I: Fundamentals (part1)

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    2/30

    1.2 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Contents..Contents..

    s

    What Operating Systems Dos Computer-System Organization

    s Computer-System Architecture

    s Operating-System Structure

    s Operating-System Operations

    s Process Management

    s Memory Management

    s Storage Management

    s Operating System Services

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    3/30

    1.3 Silberschatz, Galvin and Gagne 2005Operating System Principles

    ObjectivesObjectives

    s

    To provide a grand tour of the major operating systemscomponents

    s To provide coverage of basic computer system organization

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    4/30

    1.4 Silberschatz, Galvin and Gagne 2005Operating System Principles

    What is an Operating System?What is an Operating System?

    s A program that acts as an intermediary between a user of acomputer and the computer hardware.

    s Operating system goals:

    q Execute user programs and make solving user problemseasier.

    q Make the computer system convenient to use.

    s Use the computer hardware in an efficient manner.

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    5/30

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    6/30

    1.6 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Four Components of a Computer SystemFour Components of a Computer System

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    7/301.7 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Operating System DefinitionOperating System Definition

    s OS is a resource allocatorq Manages all resources

    q Decides between conflicting requests for efficient and fairresource use

    s OS is a control program

    q Controls execution of programs to prevent errors and improperuse of the computer

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    8/301.8 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Operating System Definition (Cont.)Operating System Definition (Cont.)

    s No universally accepted definition

    s Everything a vendor ships when you order an operating systemis good approximation

    q But varies wildly

    s The one program running at all times on the computer is thekernel. Everything else is either a system program (ships withthe operating system) or an application program

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    9/301.9 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Operating System GenerationOperating System Generation

    s Operating systems are designed to run on any of a class ofmachines; the system must be configured for each specificcomputer site

    s Booting starting a computer by loading the kernel

    s Bootstrap program code stored in ROM that is able to locate thekernel, load it into memory, and start its execution

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    10/301.10 Silberschatz, Galvin and Gagne 2005Operating System Principles

    System BootSystem Boot

    s Operating system must be made available to hardware so hardware can start

    it

    q Small piece of code bootstrap loader, locates the kernel, loads it intomemory, and starts it.

    s bootstrap program is loaded at power-up or reboot

    q Typically stored in ROM or EEPROM, generally known as firmware

    q Initializates all aspects of system

    q Loads operating system kernel and starts execution

    s Sometimes two-step process where boot block at fixed location loadsbootstrap loader

    s When power initialized on system, execution starts at a fixed memory location

    q

    Firmware used to hold initial boot code

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    11/301.11 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Computer System OrganizationComputer System Organization

    s Computer-system operation

    q One or more CPUs, device controllers connect throughcommon bus providing access to shared memory

    q Concurrent execution of CPUs and devices competing formemory cycles

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    12/301.12 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Computer-System OperationComputer-System Operation

    s I/O devices and the CPU can execute concurrently.

    s Each device controller is in charge of a particular device type.

    s Each device controller has a local buffer.

    s CPU moves data from/to main memory to/from local buffers

    s I/O is from the device to local buffer of controller.

    s Device controller informs CPU that it has finished its operation bycausing an interrupt.

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    13/301.13 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Common Functions of InterruptsCommon Functions of Interrupts

    s Interrupt transfers control to the interrupt service routine generally,through the interrupt vector, which contains the addresses of all theservice routines.

    s Interrupt architecture must save the address of the interruptedinstruction.

    s Incoming interrupts are disabledwhile another interrupt is beingprocessed to prevent a lost interrupt.

    s A trapis a software-generated interrupt caused either by an error ora user request.

    s An operating system is interruptdriven.

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    14/301.14 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Storage StructureStorage Structure

    s Main memory only large storage media that the CPU can accessdirectly.

    s Secondary storage extension of main memory that provides largenonvolatile storage capacity.

    s Magnetic disks rigid metal or glass platters covered with magneticrecording material

    q Disk surface is logically divided into tracks, which aresubdivided into sectors.

    q The disk controllerdetermines the logical interaction betweenthe device and the computer.

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    15/301.15 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Storage HierarchyStorage Hierarchy

    s Storage systems organized in hierarchy.

    q Speed

    q Cost

    q Volatility

    s Caching copying information into faster storage system; main

    memory can be viewed as a last cachefor secondary storage.

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    16/301.16 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Storage-Device HierarchyStorage-Device Hierarchy

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    17/301.17 Silberschatz, Galvin and Gagne 2005Operating System Principles

    CachingCaching

    s Important principle, performed at many levels in a computer (inhardware, operating system, software)

    s Information in use copied from slower to faster storage temporarily

    s Faster storage (cache) checked first to determine if information isthere

    q

    If it is, information used directly from the cache (fast)q If not, data copied to cache and used there

    s Cache smaller than storage being cached

    q Cache management important design problem

    q Cache size and replacement policy

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    18/301.18 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Performance of Various Levels of StoragePerformance of Various Levels of Storage

    s Movement between levels of storage hierarchy can be explicit orimplicit

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    19/301.19 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Migration of Integer A from Disk to RegisterMigration of Integer A from Disk to Register

    s Multitasking environments must be careful to use most recentvalue, not matter where it is stored in the storage hierarchy

    s Multiprocessor environment must provide cache coherency inhardware such that all CPUs have the most recent value in theircache.

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    20/301.20 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Cache and Main MemoryCache and Main Memory

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    21/301.21 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Operating System StructureOperating System Structure

    s Multiprogramming needed for efficiency

    q Single user cannot keep CPU and I/O devices busy at all times

    q Multiprogramming organizes jobs (code and data) so CPU always has oneto execute

    q A subset of total jobs in system is kept in memory

    q One job selected and run via job scheduling

    q When it has to wait (for I/O for example), OS switches to another jobs Timesharing (multitasking) is logical extension in which CPU switches jobs

    so frequently that users can interact with each job while it is running, creatinginteractive computing

    q Response time should be < 1 second

    q Each user has at least one program executing in memory process

    q If several jobs ready to run at the same time CPU schedulingq If processes dont fit in memory, swapping moves them in and out to run

    q Virtual memory allows execution of processes not completely in memory

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    22/301.22 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Memory Layout for Multiprogrammed SystemMemory Layout for Multiprogrammed System

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    23/30

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    24/30

    1.24 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Transition from User to Kernel ModeTransition from User to Kernel Mode

    s Timer to prevent infinite loop / process hogging resources

    q Set interrupt after specific period

    q Operating system decrements counter

    q When counter zero generate an interrupt

    q Set up before scheduling process to regain control or terminate

    program that exceeds allotted time

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    25/30

    1.25 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Process ManagementProcess Management

    s

    A process is a program in execution. It is a unit of work within the system.Program is a passive entity, process is an active entity.

    s Process needs resources to accomplish its task

    q CPU, memory, I/O, files

    q Initialization data

    s Process termination requires reclaim of any reusable resources

    s Single-threaded process has one program counter specifying location ofnext instruction to execute

    q Process executes instructions sequentially, one at a time, untilcompletion

    s Multi-threaded process has one program counter per thread

    s Typically system has many processes, some user, some operating system

    running concurrently on one or more CPUsq Concurrency by multiplexing the CPUs among the processes / threads

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    26/30

    1.26 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Process Management ActivitiesProcess Management Activities

    The operating system is responsible for the following activities inconnection with process management:

    s Creating and deleting both user and system processes

    s Suspending and resuming processes

    s Providing mechanisms for process synchronization

    s Providing mechanisms for process communications Providing mechanisms for deadlock handling

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    27/30

    1.27 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Memory ManagementMemory Management

    s All data in memory before and after processing

    s All instructions in memory in order to execute

    s Memory management determines what is in memory when

    q Optimizing CPU utilization and computer response to users

    s Memory management activities

    q Keeping track of which parts of memory are currently beingused and by whom

    q Deciding which processes (or parts thereof) and data to moveinto and out of memory

    q Allocating and deallocating memory space as needed

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    28/30

    1.28 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Storage ManagementStorage Management

    sOS provides uniform, logical view of information storageq Abstracts physical properties to logical storage unit - file

    q Each medium is controlled by device (i.e., disk drive, tape drive)

    Varying properties include access speed, capacity, data-transfer rate, access method (sequential or random)

    sFile-System managementq Files usually organized into directories

    q Access control on most systems to determine who can accesswhat

    q OS activities include

    Creating and deleting files and directories Primitives to manipulate files and dirs

    Mapping files onto secondary storage

    Backup files onto stable (non-volatile) storage media

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    29/30

    1.29 Silberschatz, Galvin and Gagne 2005Operating System Principles

    Mass-Storage ManagementMass-Storage Management

    s Usually disks used to store data that does not fit in main memory or data

    that must be kept for a long period of time.

    s Proper management is of central importance

    s Entire speed of computer operation hinges on disk subsystem and itsalgorithms

    s OS activities

    q Free-space managementq Storage allocation

    q Disk scheduling

    s Some storage need not be fast

    q Tertiary storage includes optical storage, magnetic tape

    q Still must be managed

    q Varies between WORM (write-once, read-many-times) and RW (read-write)

  • 8/3/2019 OS-Unit I -part 1-Thomas sir

    30/30