Docstoc

ch2

Document Sample
ch2 Powered By Docstoc
					Chapter 2: System Structures
Objectives

      To describe the services an operating system
       provides to users, processes, and other systems
      To discuss the various ways of structuring an
       operating system
      To explain how operating systems are installed
       and customized and how they boot
Chapter 2: Operating-System Structures
      Operating System Services
      User Operating System Interface
      System Calls
      Types of System Calls
      System Programs
      Operating System Design and Implementation
      Operating System Structure
      Virtual Machines
      Operating System Generation
      System Boot
1. Operating System Services
   An OS provides an environment for the execution of programs.
   It provides certain services to programs and to the users of those programs.
   One set of operating-system services provides functions that are helpful
    to the user.
           User interface

           Program execution

           I/O operations

           File-system manipulation

           Communications

           Error detection

   Another set of OS functions exists for ensuring the efficient operation of
    the system.
           Resource Allocation

           Accounting

           Protection and Security
2. User Operating System Interface
   Command Line Interface or Command Interpreter
       It allows user to directly enter commands to be performed by the OS.
       On the systems with multiple command interpreters to choose from the
        interpreters are known as shells.
       The main function of the command interpreter is to get and execute the
        next specified command.
       The commands can be implemented in two ways:
            The command interpreter itself contains the code to execute
              command.
            To implement commands through system programs, i.e. the
              command interpreter does not understand the command, it uses the
              command to identify a file to be loaded into memory and executed.
   Graphical User Interface
       User employ a mouse based ,window and menu system.
       The user moves mouse to position its pointer on images, icons on the
        screen that represent programs, files, directories, and system functions.
3. System Calls
   System calls provide an interface to the services made available by the
    OS.
   This calls are generally available in the form of routines written in a
    high-level language (C or C++).
   Mostly accessed by programs via a high-level Application Program
    Interface (API) rather than direct system call use.
   Three most common APIs are Win32 API for Windows, POSIX API for
    POSIX-based systems (including virtually all versions of UNIX, Linux,
    and Mac OS X), and Java API for the Java virtual machine (JVM)
   Why use APIs rather than system calls?
      Program portability ( the program can run on any system that
        supports the same API)
      Actual system calls can often be more detailed and difficult to work
        with than the API available to an application programmer.
3. System Calls ( Example of System Calls )
    System call sequence to copy the contents of one file to another file
3. System Calls (System Call Implementation)
    Typically, a number associated with each system call
       System-call interface maintains a table indexed according to
        these numbers
    The system call interface invokes intended system call in OS
     kernel and returns status of the system call and any return values
    The caller need know nothing about how the system call is
     implemented
       Just needs to obey API and understand what OS will do as a
        result call
       Most details of OS interface hidden from programmer by API
           Managed by run-time support library (set of functions built
            into libraries included with compiler)
3. System Calls (API – System Call – OS Relationship )
3. System Calls ( Standard C Library Example )

       C program invoking printf() library call, which calls write()
        system call
3. System Calls ( System Call Parameter Passing )
     Often, more information is required than simply identity of desired
      system call
        Exact type and amount of information vary according to OS and
          call
     Three general methods used to pass parameters to the OS
        Simplest: pass the parameters in registers
             In some cases, may be more parameters than registers

        Parameters stored in a block, or table, in memory, and address
          of block passed as a parameter in a register
             This approach taken by Linux and Solaris

        Parameters placed, or pushed, onto the stack by the program
          and popped off the stack by the operating system
        Block and stack methods do not limit the number or length of
          parameters being passed
3. System Calls ( Parameter Passing via Table )
4. Types of System Calls
   Process control :
        end ,abort
        load, execute
        create, terminate
        get and set process attributes
        allocate and free memory
   File management:
        create , delete file
        open, close
        read, write, reposition
        get and set file attributes
   Device management:
        request and release device
        read, write, reposition
        get and set device attributes
   Information maintenance:
        get and set time or date
        get and set system data
   Communications:
        send , receive messages
        attach or detach devices
MS-DOS execution




         (a) At system startup (b) running a program
FreeBSD Running Multiple Programs
5. System Programs
   System programs also known as System Utilities, provide a
    convenient environment for program development and execution.
    The can be divided into:
      File manipulation – create,delete,copy,rename,list files
      Status information – system date, time, available memory,
       number of users, information about performance, logging,etc.
      File modification – text editors to create, modify files.
      Programming language support – compilers, assemblers,
       interpreters.
      Program loading and execution – absolute, relocatable, overlay
       loaders.
      Communications
      Application programs
   Most users’ view of the operation system is defined by system
    programs, not the actual system calls.
    6. OS Design and Implementation
    Design Goals
       The design of the system will be affected by the choice of hardware and the
        type of system.
       Requirements can be divided into user goals and system goals.
       The system should be easy to learn and use, fast and reliable.
       The system should be easy to design, implement and maintain, it should be
        error free and efficient.
    Mechanisms and Policies
       Mechanisms determines how to do something
       Policies determine what will be done.
       For eg. the timer construct is a mechanism for ensuring CPU protection, but
        deciding hoe long the timer is to be set for a particular user is a policy
        decision.
    Implementation
       Once OS is designed it must be implemented.
       Earlier OS were written in assembly language now they are mostly written in
        C or C++.
7. Operating System Structure (Simple Structure)
   SIMPLE STRUCTURE
   Have no well defined structure.
   MS-DOS – written to provide the
    most functionality in the least space
   Not divided into modules
   Although MS-DOS has some
    structure, its interfaces and levels of
    functionality are not well separated
   The application programs are able to
    access the basic I/O routines, it there
    is malicious program it causes the
    entire system crash.
   In this type of structure enormous
    amount of functionality is combined
    into one level.
   This monolithic structure is difficult to
    implement and maintain.
7. Operating System Structure (Layered Operating System)
    LAYERED APPORACH
    The OS can be broken into pieces that are smaller and more manageable.
    The OS can then retain much greater control over the computer and over the
     applications that make use of that computer.
    Overall functionality and features are determined and separated into
     components.
    The operating system is divided into a number of layers (levels), each built on
     top of lower layers. The bottom layer (layer 0), is the hardware; the highest
     (layer N) is the user interface.
    With modularity, layers are selected such that each uses functions
     (operations) and services of only lower-level layers.
    The main advantage of the layered approach is simplicity of construction and
     debugging.
    Each layer is implemented with only those operations provided by lower level
     layers.
    A layer does not need to know how these operations are implemented, it
      needs to know only what these operations do.
    Hence each layer hides the existence of certain data structures, operations
     and hardware from higher level layers.
7. Operating System Structure (Layered Operating System)
   The major difficulty is involved in appropriately
    defining various layers.
   As a layer can use only lower level
       layers careful planning is required.
   For eg, the device driver for backing store must
    be at a lower level than the memory
    mgmt routines, because memory mgmt
    requires the ability to use the backing store.
 Also they tend to be less efficient.
 For eg, when a user program executes an I/O operation,
      It executes a system call that is trapped to the I/O layer.
      which calls the memory management layer
      which in turn calls the CPU scheduling layer
      which is then passed to the hardware.
 At each layer, the parameter may be modified, data may need to be passed, and
 so on, so each layer adds overhead to the system call, the net result is a system
 call takes longer time than for nonlayered system.
7. Operating System Structure                                (Microkernel)

   MICROKERNELS
   This method structures the OS by removing all nonessential components from
    the kernel and implementing them as system and user level programs.
   Moves as much from the kernel into “user” space.
   The main function of microkernel is to provide a communication facility between
    the client program and the various services that are also running in user space.
   Communication is provided by message passing.
   Benefits:
      Easier to extend a microkernel
      Easier to port the operating system to new architectures
      More reliable (less code is running in kernel mode)
      More secure
   Detriments:
      Performance overhead of user space to kernel space communication
7. Operating System Structure   (Microkernel)
7. Operating System Structure                       (Modules)



   MODULES
   Most modern operating systems
    implement kernel modules
      Uses object-oriented approach
      Each core component is
       separate
      Each talks to the others over
       known interfaces
      Each is loadable as needed
       within the kernel
   Overall, similar to layers but with
    more flexible
                                          Solaris Modular Approach
8. Virtual Machines
   In computer science, a virtual machine (VM) is a software
    implementation of a machine (computer) that executes programs like
    a real machine.
   The main idea behind a virtual machine is to abstract the hardware
    of a single computer (the CPU, memory, disk drives, n/w i/f cards,
    etc. ) into several different execution environment, thereby creating
    the illusion that each separate execution environment is running its
    own private computer.
   By using CPU scheduling and virtual memory techniques an OS host
    can create the illusion that a process has its own processor with its
    own memory.
   A virtual machine provides an interface identical to the underlying
    bare hardware.
   The operating system creates the illusion of multiple processes,
    each executing on its own processor with its own (virtual) memory.
8. Virtual Machines
    Virtual machines are separated into two major
     categories, based on their use and degree of
     correspondence to any real machine.
    A system virtual machine provides a complete
     system platform which supports the execution of a
     complete operating system (OS).
     In contrast, a process virtual machine is designed
     to run a single program, which means that it
     supports a single process CPU scheduling can
     create the appearance that users have their own
     processor
8. Virtual Machines




          Non-virtual Machine   Virtual Machine
8. Virtual Machines
    System virtual machines (sometimes called hardware virtual
     machines) allow the sharing of the underlying physical machine
     resources between different virtual machines, each running its own
     operating system.
     The main advantages of system VMs are:
       multiple OS environments can co-exist on the same computer,
        in strong isolation from each other
       the virtual machine can provide an instruction set architecture
        (ISA) that is somewhat different from that of the real machine
       application provisioning, maintenance, high availability and
        disaster recovery
8. Virtual Machines




          VMware Architecture
8. Virtual Machines
    A process VM, sometimes called an application virtual
     machine, runs as a normal application inside an OS and
     supports a single process. It is created when that process is
     started and destroyed when it exits. Its purpose is to provide
     a platform-independent programming environment that
     abstracts away details of the underlying hardware or
     operating system, and allows a program to execute in the
     same way on any platform.
    This type of VM has become popular with the Java
     programming language, which is implemented using the Java
     virtual machine. Another example is the .NET Framework,
     which runs on a VM called the Common Language Runtime.
8. Virtual Machines




            The Java Virtual Machine




          Java portability across platforms.
8. Virtual Machines
                     C++             VB.Net
                    Source           source
     compilation
                     MS-IL            MS-IL
                   assembly         assembly



                   CLR
                         Just in time compiler




                             Host system


              Architecture of the CLR for the .NET framework.
9. Operating System Generation
   Operating systems are designed to run on any of a class of machines;
    the system must be configured for each specific computer site
   SYSGEN program obtains information concerning the specific
    configuration of the hardware system, the following kind of information
    must be determined,
      What CPU is to be used? What options are installed ? (floating
        point arithmetic, instruction set, etc.)
      How much memory is available?
      What devices are available? (how to address of device, the device
        interrupt number, the device’s type and model, etc. )
      What OS options are desired? What parameter values are to be
        used? ( these values/ options include how many buffers of which
        size should be used, what type of CPU scheduling algorithm is
        desired, what is the maximum number of processes to be
        supported )
10. System Boot

    Operating system must be made available to
     hardware so hardware can start it
       Small piece of code – bootstrap loader,
        locates the kernel, loads it into memory, and
        starts it
       Sometimes two-step process where boot
        block at fixed location loads bootstrap loader
       When power initialized on system, execution
        starts at a fixed memory location
           Firmware used to hold initial boot code
End of Chapter 2

				
DOCUMENT INFO
Shared By:
Tags: how to, coding
Stats:
views:69
posted:8/28/2010
language:English
pages:34