Top Banner

of 42

Ch03 Operating-System Structures 2

Jun 02, 2018

Download

Documents

Paolo Zafra
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/10/2019 Ch03 Operating-System Structures 2

    1/42

    Silberschatz, Galvin and Gagne 20021 / 42Operating System Concepts

    Chapter 3: Operating-System Structures

    3.1 System Components

    3.2 Operating System Services

    3.3 System Calls

    3.4 System Programs

    3.5 System Structure

    3.6 Virtual Machines

    3.7 System Design and Implementation 3.8 System Generation

  • 8/10/2019 Ch03 Operating-System Structures 2

    2/42

    Silberschatz, Galvin and Gagne 20022 / 42Operating System Concepts

    3.1 System Components

    3.1.1 Process Management

    3.1.2 Main Memory Management

    3.1.3 File Management

    3.1.4 I/O System Management

    3.1.5 Secondary Management 3.1.6 Networking

    3.1.7 Protection System

    3.1.8 Command-Interpreter System

  • 8/10/2019 Ch03 Operating-System Structures 2

    3/42

    Silberschatz, Galvin and Gagne 20023 / 42Operating System Concepts

    3.1.1 Process Management

    Aprocess is a program in execution. A processneeds certain resources, including CPU time,memory, files, and I/O devices, to accomplish

    its task.

    The operating system is responsible for thefollowing activities in connection with process

    management. Process creation and deletion.

    process suspension and resumption.

    Provision of mechanisms for:

    process synchronization process communication

  • 8/10/2019 Ch03 Operating-System Structures 2

    4/42Silberschatz, Galvin and Gagne 20024 / 42Operating System Concepts

    3.1.2 Main-Memory Management

    Memory is a large array of words or bytes, eachwith its own address. It is a repository ofquickly accessible data shared by the CPU and

    I/O devices. Main memory is a volatile storage device. It

    loses its contents in the case of system failure.

    The operating system is responsible for thefollowing activities in connections with memorymanagement: Keep track of which parts of memory are currently being

    used and by whom. Decide which processes to load when memory space

    becomes available.

    Allocate and deallocate memory space as needed.

  • 8/10/2019 Ch03 Operating-System Structures 2

    5/42Silberschatz, Galvin and Gagne 20025 / 42Operating System Concepts

    3.1.3 File Management

    A file is a collection of related information

    defined by its creator. Commonly, filesrepresent programs (both source and objectforms) and data.

    The operating system is responsible for the

    following activities in connections with filemanagement: File creation and deletion.

    Directory creation and deletion.

    Support of primitives for manipulating files and directories.

    Mapping files onto secondary storage.

    File backup on stable (nonvolatile) storage media.

  • 8/10/2019 Ch03 Operating-System Structures 2

    6/42Silberschatz, Galvin and Gagne 20026 / 42Operating System Concepts

    3.1.4 I/O System Management

    The I/O system consists of:

    A buffer-caching systemA general device-driver interface

    Drivers for specific hardware devices

  • 8/10/2019 Ch03 Operating-System Structures 2

    7/42Silberschatz, Galvin and Gagne 20027 / 42Operating System Concepts

    3.1.5 Secondary-Storage Management

    Since main memory (primary storage) is volatileand too small to accommodate all data andprograms permanently, the computer system

    must provide secondary storage to back upmain memory.

    Most modern computer systems use disks asthe principle on-line storage medium, for bothprograms and data.

    The operating system is responsible for thefollowing activities in connection with disk

    management: Free space management

    Storage allocation

    Disk scheduling

  • 8/10/2019 Ch03 Operating-System Structures 2

    8/42Silberschatz, Galvin and Gagne 20028 / 42Operating System Concepts

    3.1.6 Networking (Distributed Systems)

    A distributedsystem is a collection processors

    that do not share memory or a clock. Eachprocessor has its own local memory.

    The processors in the system are connectedthrough a communication network.

    Communication takes place using aprotocol.

    A distributed system provides user access tovarious system resources.

    Access to a shared resource allows: Computation speed-up

    Increased data availability

    Enhanced reliability

  • 8/10/2019 Ch03 Operating-System Structures 2

    9/42Silberschatz, Galvin and Gagne 20029 / 42Operating System Concepts

    3.1.7 Protection System

    Protection refers to a mechanism for

    controlling access by programs,processes, or users to both system and

    user resources.

    The protection mechanism must: distinguish between authorized and unauthorized

    usage.

    specify the controls to be imposed.

    provide a means of enforcement.

  • 8/10/2019 Ch03 Operating-System Structures 2

    10/42

    Silberschatz, Galvin and Gagne 200210 / 42Operating System Concepts

    3.1.8 Command-Interpreter System

    Many commands are given to the

    operating system by control statementswhich deal with: process creation and management

    I/O handling secondary-storage management

    main-memory management

    file-system access protection

    networking

  • 8/10/2019 Ch03 Operating-System Structures 2

    11/42

    Silberschatz, Galvin and Gagne 200211 / 42Operating System Concepts

    Command-Interpreter System (Cont.)

    The program that reads and interprets

    control statements is called variously:

    command-line interpreter

    shell (in UNIX)

    Its function is to get and execute thenext command statement.

    3 2 O ti S t S i

  • 8/10/2019 Ch03 Operating-System Structures 2

    12/42

    Silberschatz, Galvin and Gagne 200212 / 42Operating System Concepts

    3.2 Operating System Services

    Program execution system capability to load a

    program into memory and to run it. I/O operations since user programs cannot

    execute I/O operations directly, the operating

    system must provide some means to performI/O.

    File-system manipulation program capabilityto read, write, create, and delete files.

    Communications exchange of informationbetween processes executing either on thesame computer or on different systems tied

    together by a network. Implemented via sharedmemoryor message passing.

    Error detection ensure correct computing bydetecting errors in the CPU and memoryhardware, in I/O devices, or in user programs.

  • 8/10/2019 Ch03 Operating-System Structures 2

    13/42

    Silberschatz, Galvin and Gagne 200213 / 42Operating System Concepts

    Additional Operating System Functions

    Additional functions exist not for helping

    the user, but rather for ensuring efficient

    system operations. Resource allocation allocating resources to multipleusers or multiple jobs running at the same time.

    Accounting keep track of and record which usersuse how much and what kinds of computer resourcesfor account billing or for accumulating usage statistics.

    Protection ensuring that all access to systemresources is controlled.

  • 8/10/2019 Ch03 Operating-System Structures 2

    14/42

    Silberschatz, Galvin and Gagne 200214 / 42Operating System Concepts

    3.3 System Calls

    System calls provide the interface between arunning program and the operating system. Generally available as assembly-language instructions.

    Languages defined to replace assembly language forsystems programming allow system calls to be made directly(e.g., C, C++)

    Three general methods are used to passparameters between a running program andthe operating system. Pass parameters in registers.

    Store the parameters in a table in memory, and the tableaddress is passed as a parameter in a register.

    Push (store) the parameters onto the stackby the program,andpop off the stack by operating system.

  • 8/10/2019 Ch03 Operating-System Structures 2

    15/42

    Silberschatz, Galvin and Gagne 200215 / 42Operating System Concepts

    Fig 3.1 Passing of Parameters As A Table

  • 8/10/2019 Ch03 Operating-System Structures 2

    16/42

    Silberschatz, Galvin and Gagne 200216 / 42Operating System Concepts

    Types of System Calls

    Process control

    File management

    Device management

    Information maintenance Communications

  • 8/10/2019 Ch03 Operating-System Structures 2

    17/42

    Silberschatz, Galvin and Gagne 200217 / 42Operating System Concepts

    Fig 3.3 MS-DOS Execution

    At System Start-up Running a Program

  • 8/10/2019 Ch03 Operating-System Structures 2

    18/42

    Silberschatz, Galvin and Gagne 200218 / 42Operating System Concepts

    Fig 3.4 UNIX Running Multiple Programs

    Fi 3 5 C i ti M d l

  • 8/10/2019 Ch03 Operating-System Structures 2

    19/42

    Silberschatz, Galvin and Gagne 200219 / 42Operating System Concepts

    Fig 3.5 Communication Models

    Communication may take place usingeither message passing or shared

    memory.

    Shared MemoryMsg Passing

    3 4 S t P

  • 8/10/2019 Ch03 Operating-System Structures 2

    20/42

    Silberschatz, Galvin and Gagne 200220 / 42Operating System Concepts

    3.4 System Programs

    System programs provide a convenientenvironment for program development andexecution. The programs can be divided into: File manipulation Status information

    File modification

    Programming language support

    Program loading and execution

    Communications

    Application programs

    Most users view of the operation system isdefined by system programs, not the actualsystem calls.

    3 5 S t St t

  • 8/10/2019 Ch03 Operating-System Structures 2

    21/42

    Silberschatz, Galvin and Gagne 200221 / 42Operating System Concepts

    3.5 System Structure

    3.5.1 Simple Structure

    MS-DOS written to provide the mostfunctionality in the least space not divided into modules

    Although MS-DOS has some structure, its interfacesand levels of functionality are not well separated

    Fig 3 6 MS DOS La er Str ct re

  • 8/10/2019 Ch03 Operating-System Structures 2

    22/42

    Silberschatz, Galvin and Gagne 200222 / 42Operating System Concepts

    Fig 3.6 MS-DOS Layer Structure

    UNIX System Structure

  • 8/10/2019 Ch03 Operating-System Structures 2

    23/42

    Silberschatz, Galvin and Gagne 200223 / 42Operating System Concepts

    UNIX System Structure

    UNIX limited by hardware functionality,

    the original UNIX operating system had

    limited structuring. The UNIX OSconsists of two separable parts. Systems programs

    The kernelConsists of everything below the system-call interface

    and above the physical hardware

    Provides the file system, CPU scheduling, memory

    management, and other operating-system functions; alarge number of functions for one level.

    Fig 3 7 UNIX System Structure

  • 8/10/2019 Ch03 Operating-System Structures 2

    24/42

    Silberschatz, Galvin and Gagne 200224 / 42Operating System Concepts

    Fig 3.7 UNIX System Structure

    3 5 2 Layered Approach

  • 8/10/2019 Ch03 Operating-System Structures 2

    25/42

    Silberschatz, Galvin and Gagne 200225 / 42Operating System Concepts

    3.5.2 Layered Approach

    The operating system is divided into a

    number of layers (levels), each built ontop 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.

    Fig 3 8 An Operating System Layer

  • 8/10/2019 Ch03 Operating-System Structures 2

    26/42

    Silberschatz, Galvin and Gagne 200226 / 42Operating System Concepts

    Fig 3.8 An Operating System Layer

  • 8/10/2019 Ch03 Operating-System Structures 2

    27/42

    Silberschatz, Galvin and Gagne 200227 / 42Operating System Concepts

    Layered Structure of the THE OS

    A layered design was first used in THEoperating system. Its six layers are as

    follows:

    la ye r 5 : u se r p ro gra m s

    la ye r 4 : b u ffe r in g fo r in p u t a n d o u t p u t

    la ye r 3 : o p e ra to r -c o n s o le d e v ic e d rive r

    la ye r 2 : m e m o ry m a na g em e nt

    la ye r 1 : C P U s c h e d ulin g

    la ye r 0 : h a rd w a re

    Fig 3 9 OS/2 Layer Structure

  • 8/10/2019 Ch03 Operating-System Structures 2

    28/42

    Silberschatz, Galvin and Gagne 200228 / 42Operating System Concepts

    Fig 3.9 OS/2 Layer Structure

    3 5 3 Microkernel System Structure

  • 8/10/2019 Ch03 Operating-System Structures 2

    29/42

    Silberschatz, Galvin and Gagne 200229 / 42Operating System Concepts

    3.5.3 Microkernel System Structure

    Moves as much from the kernel into

    Communication takes place between user

    Benefits:- easier to extend a microkernel

    - easier to port the operating system to

    - more reliable (less code is running in

    - more secure

  • 8/10/2019 Ch03 Operating-System Structures 2

    30/42

    Silberschatz, Galvin and Gagne 200230 / 42Operating System Concepts

    Fig 3.10 Windows NT Client-Server

    Structure

    3 6 Virtual Machines

  • 8/10/2019 Ch03 Operating-System Structures 2

    31/42

    Silberschatz, Galvin and Gagne 200231 / 42Operating System Concepts

    3.6 Virtual Machines

    A virtual machine takes the layeredapproach to its logical conclusion. Ittreats hardware and the operating system

    kernel as though they were all hardware.A virtual machine provides an interface

    identicalto the underlying bare hardware.

    The operating system creates the illusionof multiple processes, each executing onits own processor with its own (virtual)

    memory.

    Virtual Machines (Cont.)

  • 8/10/2019 Ch03 Operating-System Structures 2

    32/42

    Silberschatz, Galvin and Gagne 200232 / 42Operating System Concepts

    Virtual Machines (Cont.)

    The resources of the physical computerare shared to create the virtual

    machines.

    CPU scheduling can create the appearancethat users have their own processor.

    Spooling and a file system can provide virtual

    card readers and virtual line printers.

    A normal user time-sharing terminal serves

    as the virtual machine operators console.

    Fig 3.11 System Models

  • 8/10/2019 Ch03 Operating-System Structures 2

    33/42

    Silberschatz, Galvin and Gagne 200233 / 42Operating System Concepts

    Fig 3.11 System Models

    Virtual MachineNon-virtual Machine

    Advantages/Disadvantages of Virtual Machines

  • 8/10/2019 Ch03 Operating-System Structures 2

    34/42

    Silberschatz, Galvin and Gagne 200234 / 42Operating System Concepts

    g g

    The virtual-machine concept provides completeprotection of system resources since each virtualmachine is isolated from all other virtual

    machines. This isolation, however, permits nodirect sharing of resources.

    A virtual-machine system is a perfect vehicle for

    operating-systems research and development.System development is done on the virtualmachine, instead of on a physical machine and

    so does not disrupt normal system operation. The virtual machine concept is difficult to

    implement due to the effort required to provide an

    exactduplicate to the underlying machine.

    3.6.3 Java Virtual Machine

  • 8/10/2019 Ch03 Operating-System Structures 2

    35/42

    Silberschatz, Galvin and Gagne 200235 / 42Operating System Concepts

    Compiled Java programs are platform-

    neutral bytecodes executed by a JavaVirtual Machine (JVM).

    JVM consists of

    - class loader- class verifier

    - runtime interpreter

    Just-In-Time (JIT) compilers increaseperformance

    Fig 3.12 Java Virtual Machine

  • 8/10/2019 Ch03 Operating-System Structures 2

    36/42

    Silberschatz, Galvin and Gagne 200236 / 42Operating System Concepts

    g

    3.7 System Design Goals

  • 8/10/2019 Ch03 Operating-System Structures 2

    37/42

    Silberschatz, Galvin and Gagne 200237 / 42Operating System Concepts

    y g

    3.7.1 Design GoalsUser goals operating system should

    be convenient to use, easy to learn,

    reliable, safe, and fast.

    System goals operating system

    should be easy to design, implement,

    and maintain, as well as flexible,reliable, error-free, and efficient.

    3.7.2 Mechanisms and Policies

  • 8/10/2019 Ch03 Operating-System Structures 2

    38/42

    Silberschatz, Galvin and Gagne 200238 / 42Operating System Concepts

    Mechanisms determine how to do

    something, policies decide what will bedone.

    The separation of policy from

    mechanism is a very important principle,it allows maximum flexibility if policy

    decisions are to be changed later.

    3.7.3 System Implementation

  • 8/10/2019 Ch03 Operating-System Structures 2

    39/42

    Silberschatz, Galvin and Gagne 200239 / 42Operating System Concepts

    y p

    Traditionally written in assembly language,operating systems can now be written in

    higher-level languages.

    Code written in a high-level language: can be written faster.

    is more compact.

    is easier to understand and debug.

    An operating system is far easier toport

    (move to some other hardware) if it iswritten in a high-level language.

    3.8 System Generation (SYSGEN)

  • 8/10/2019 Ch03 Operating-System Structures 2

    40/42

    Silberschatz, Galvin and Gagne 200240 / 42Operating System Concepts

    Operating systems are designed to run on any of aclass of machines; the system must be configured

    for each specific computer site.

    SYSGEN program obtains information concerningthe specific configuration of the hardware system.

    Booting starting a computer by loading the

    kernel.Bootstrap program code stored in ROM that is

    able to locate the kernel, load it into memory, and

    start its execution.

    Exercises:

  • 8/10/2019 Ch03 Operating-System Structures 2

    41/42

    Silberschatz, Galvin and Gagne 200241 / 42Operating System Concepts

    3.6

    3.7

  • 8/10/2019 Ch03 Operating-System Structures 2

    42/42

    Silberschatz, Galvin and Gagne 200242 / 42Operating System Concepts

    THE EN