Chapter 3 OperatingSystem Structures - PowerPoint PPT Presentation

1 / 54
About This Presentation
Title:

Chapter 3 OperatingSystem Structures

Description:

Security ensuring that system resources are used and accessed as intended ... Communication takes place between user modules using message passing. Benefits ... – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 55
Provided by: web2CcN
Category:

less

Transcript and Presenter's Notes

Title: Chapter 3 OperatingSystem Structures


1
Chapter 3 Operating-System Structures
2
Outline
  • System Components
  • Operating System Services
  • System Calls
  • System Programs
  • System Structure
  • Virtual Machines
  • System Design and Implementation
  • System Generation
  • Advanced Information

3
Common System Components
  • Process Management
  • Main Memory Management
  • File Management
  • I/O System Management
  • Secondary-Storage Management
  • Networking
  • Protection System
  • Command-Interpreter System

4
Process Management
  • A process is a program in execution
  • Needs certain resources, including CPU time,
    memory, files, and I/O devices, to accomplish its
    task.
  • Operating-system process vs. user process
  • OS is responsible for
  • Process creation and deletion
  • Process suspension and resumption
  • Provision of mechanisms for
  • Process synchronization
  • Process communication
  • Deadlock handling
  • Chapters 4-8

5
Main-Memory Management
  • Memory is a large array of words or bytes, each
    with its own address. It is a repository of
    quickly 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
  • A program must be mapped to absolute addresses
    and loaded into memory for execution
  • OS is responsible for
  • 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 de-allocate memory space as needed
  • Chapters 9-10

6
File Management
  • File
  • Uniform logical view of variable physical storage
    devices
  • Collection of related information programs and
    data
  • OS is responsible for
  • File/Directory creation and deletion
  • Support for manipulating files and directories
  • Mapping files onto secondary storage
  • File backup on stable (nonvolatile) storage media
  • Chapters 11-12

7
I/O System Management
  • OS is responsible for hiding the peculiarities of
    specific hardware devices from the user by the
    I/O system
  • The I/O system consists of
  • A memory-management component that includes
    buffering, caching, and spooling
  • A general device-driver interface
  • Drivers for specific hardware devices
  • Only the device driver knows the peculiarities of
    the specific device to which it is assigned
  • Chapters 2, 13

8
Secondary-Storage Management
  • Secondary storage to back up main memory
  • Main memory is too small and volatile
  • Computer systems use disks as the principle
    on-line storage medium, for both programs and
    data
  • Programs and data are brought into main memory
    when needed
  • Secondary storage must be used for efficient
    because of the speed difference with CPU
  • OS is responsible for
  • Free space management
  • Storage allocation
  • Disk scheduling
  • Chapter 14

9
Networking (Distributed Systems)
  • A distributed system is a collection processors
    that do not share memory or a clock. Each
    processor has its own local memory.
  • The processors in the system are connected
    through a communication network.
  • Communication takes place using a protocol.
  • A distributed system provides user access to
    various system resources.
  • Access to a shared resource allows
  • Computation speed-up
  • Increased data availability
  • Enhanced reliability
  • Chapters 15-17

10
Protection System
  • Protection
  • A mechanism for controlling access to both system
    and user resources by programs, processes, or
    users
  • Ensure resources can be operated on by only those
    processes having gained proper authorization from
    OS
  • The protection system must
  • Distinguish between authorized and unauthorized
    usage
  • Specify the controls to be imposed (Policy)
  • Provide a means of enforcement (Mechanism)
  • Chapter 18

11
Command-Interpreter System
  • Command interpreter
  • Interface between users and OS
  • Control-card interpreter, command-line
    interpreter, shell, mouse-based window-and-menu
    system
  • Get the next statement and execute it
  • Control statements
  • Commands given to OS from command interpreter
  • Deal with process creation and management, I/O
    handling, secondary-storage management,
    main-memory management, file-system access,
    protection, networking

12
Operating System Services
  • For the convenience of the programmer
  • Program execution
  • Load a program into memory and to run it
  • End its execution, either normally or abnormally
  • I/O operations file or I/O device
  • since user programs cannot execute I/O operations
    directly, the operating system must provide some
    means to perform I/O.
  • File-system manipulation
  • Read, write, create, and delete files.

13
Operating System Services (Cont.)
  • For the convenience of the programmer (Cont.)
  • Communications exchange of information between
    processes executing either on the same computer
    or on different systems tied together by a
    network
  • Via shared memory or message passing
  • Error detection ensure correct and consistent
    computing by detecting errors in the CPU and
    memory hardware, in I/O devices, or in user
    programs

14
Additional Operating System Functions
  • For ensuring efficient system operations
  • Resource allocation allocating resources to
    multiple users or multiple jobs running at the
    same time.
  • Accounting keep track of and record which users
    use how much and what kinds of computer resources
    for account billing or for accumulating usage
    statistics.
  • Protection ensuring that all access to system
    resources is controlled.
  • Security ensuring that system resources are
    used and accessed as intended under all
    circumstances.

15
System Calls
16
Overview
  • System calls provide the interface between a
    running program and the OS
  • Switch from user mode to kernel mode
  • Generally available as assembly-language
    instructions
  • Languages defined to replace assembly language
    for systems programming allow system calls to be
    made directly (e.g., C, C, Win32 API)
  • Categories
  • Process control
  • File manipulation
  • Device manipulation
  • Information maintenance
  • Communication

17
Overview (Cont.) -- Example
  • Read data from one file and copy them to another
  • Ask the names of the two files
  • Prompt messages on the screen
  • Read the file names from the keyboard
  • Open the input file and create the output file
  • A loop that reads from the input file and writes
    to the output file
  • Close both files
  • Terminate normally
  • Error handling or abnormally terminate

18
Overview (Cont.)
  • Most of the details of the OS interface are
    hidden from the programmer by the compiler and by
    the run-time support package
  • printf(.), cout()
  • Compiled into a call to a run-time support
    routine that issues the necessary system calls,
    check for errors, and finally returned to the
    user program

19
Parameter Passing to A System Call
  • Parameter passing between a running program and
    the OS
  • Pass parameters in registers.
  • Store the parameters in a table in memory, and
    the table address is passed as a parameter in a
    register. (Linux)
  • Push (store) the parameters onto the stack by the
    program, and pop off the stack by operating
    system.

20
Passing of Parameters As A Table
21
Types of System Calls
  • Process control
  • File management
  • Device management
  • Information maintenance
  • Communications

22
Process Control
  • Halt execution either normally (end) or
    abnormally (abort)
  • A process may load and execute another program
  • Whether the existing one is lost, saved,
    concurrent executed?
  • Create process or submit job concurrent executed
  • Get process attribute, set process attribute
  • Wait for a certain amount of time (wait time)
  • Wait for a specific event to occur (wait event,
    signal event)
  • Dump memory for debugging (dump)
  • Time profile
  • Allocate and free memory

23
MS-DOS Execution
24
UNIX Running Multiple Programs
  • Shell fork and exec a program

25
File, Device
  • File Directory Management
  • Create file, delete file
  • Open, close
  • Read, write, reposition
  • Get file attribute
  • Set file attribute
  • Device Management
  • Request device
  • Release device
  • Read, write, reposition
  • Get device attribute
  • Set device attribute
  • Logically attach or detach devices (to a logical
    device file)
  • The similarity between I/O devices and files is
    so great that many OS (including UNIX and DOS)
    merge the two into a combined file-device
    structure

26
Information and Communication
  • Information maintenance
  • Get (set) time or date
  • Get (set) system data
  • of current users
  • Version number
  • Amount of free memory
  • Get process, file, or device attribute
  • Set process, file, or device attribute
  • Communications
  • Create, delete communication connection
  • Send, receive messages
  • Transfer status information
  • Attach or detach remote devices (socket)

Communication Model 1. Message Passing 2. Shared
Message
27
Communication Models
28
System Programs
  • System program provide a convenient environment
    for program development and execution
  • Some are user interfaces to system calls
  • Categories
  • File management create/delete/rename/list files
    and directories
  • Status information ask for date, time,
    available memory
  • File modification editor
  • Programming language support compiler,
    assembler, interpreter
  • Program loading and execution loader and
    debugger
  • Communications Email, talk, web browsing
  • System utilities or application programs solve
    common problems

29
System Programs (Cont.)
  • Most users view of the operation system is
    defined by system programs, not the actual system
    calls.
  • Command interpreter (CI) perhaps the most
    important system program for an OS
  • How to implement the commands that a CI knows?
  • Internal commands CI contains the command codes
  • System programs
  • Parameter passing
  • Parameters interpretation is left up to the
    system program
  • Slower

30
System Structure
  • Partition the task into small components
  • Well-defined inputs, outputs, and function
  • How to interconnect these components

31
Simple Structure -- MS-DOS
  • MS-DOS written to provide the most
    functionality in the least space
  • Do not have a well-defined structure
  • Not divided into modules
  • Lack hardware protection and dual mode support
  • Although MS-DOS has some structure, its
    interfaces and levels of functionality are not
    well separated

32
Simple Structure Original UNIX
  • Limited by hardware functionality, the original
    UNIX OS had limited structuring
  • The UNIX OS consists of two separable parts
  • Systems programs
  • Kernel
  • Consists 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
  • A large number of functions in one level

33
General/Traditional UNIX Architecture
UI
API
SVR3, 4.3BSD, and earlier versions
34
Layered Approach
  • OS 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, each layer uses functions and
    services of only lower-level layers
  • How to do vs. What to do
  • Simplify debugging and system verification
  • Clear interface
  • Hide data structure,operation, hardware

35
An Operating System Layer
36
Layered Approach (Cont.)
  • Shortcomings
  • How to appropriately define the various layers
  • Less efficient than other types
  • Improvement
  • Fewer layers with more functionality
  • Provide most of the advantages of modularization
  • Avoid the difficult problems of layer definition
    and interaction
  • NT 4.0 moves layers from user space to kernel
    space and more closely integrating them

37
OS/2 Layer Structure
38
Micro-Kernels
  • Moves as much from the kernel into user space.
  • Smaller kernel
  • Minimal process and memory management,
    communication facility
  • Communication takes place between user modules
    using message passing
  • Benefits
  • Easier to extend a micro-kernel
  • Easier to port the operating system to new
    architectures
  • More reliable (less code is running in kernel
    mode)
  • More secure

39
Micro-Kernels (Cont.)
  • Many services traditionally included in the
    operating system are now external subsystems
  • Device drivers
  • File systems
  • Virtual memory manager
  • Windowing system
  • Security services
  • Example
  • Tru64 Unix (formally Digital UNIX)
  • Apple MacOS X Server
  • QNX real-time OS
  • Windows NT (Hybrid) -- Win32, OS/2, POSIX

40
Windows NT Client-Server Structure
41
Virtual Machines
  • A virtual machine takes the layered approach to
    its logical conclusion. It treats hardware and
    the operating system kernel as though they were
    all hardware
  • A virtual machine provides an interface identical
    to the underlying bare hardware
  • Each process is provided with a (virtual) copy of
    the underlying computer
  • OS creates the illusion of multiple processes,
    each executing on its own processor with its own
    (virtual) memory.

42
System Models
43
Virtual Machines (Cont.)
  • The resources of the physical computer are shared
    to create the virtual machines
  • CPU scheduling can create the appearance that
    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

44
Conceptual Implementation of VM
  • How to run a MS-DOS program on Sun or DEC system?
  • Create a virtual Intel machine on top of the
    native processor
  • Intel instruction are translated by the Intel VM
    to the native instruction set

Intel Application
Intel VM
VM Interpretation
Sun Kernel
Sun hardware
45
Java Technology
  • Programming-language specification
  • Object-oriented, architecture-neutral,
    distributed, secure, and multi-threaded
    programming language
  • Application-Programming Interface (API)
  • Base API graphics, I/O, utilities, networking
  • Standard extension API enterprise, security,
    media
  • Java Virtual Machine (JVM)
  • A specification for an abstract computer
  • Class loader load .class file and API
  • Class verifier
  • Run-time interpreter translate
    architecture-neutral bytecode into native machine
    language for the host computer
  • Just-In-Time (JIT) compilers increase performance

46
The Java Virtual Machine
JVM
47
Advantages/Disadvantages of Virtual Machines
  • The virtual-machine concept provides complete
    protection of system resources since each virtual
    machine is isolated from all other virtual
    machines. This isolation, however, permits no
    direct sharing of resources.
  • A virtual-machine system is a perfect vehicle for
    operating-systems research and development.
    System development is done on the virtual
    machine, 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 exact duplicate to the underlying machine.

48
System Design and Implementation
49
System Design Goals
  • User 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

50
Mechanisms and Policies
  • Mechanisms determine how to do something,
    policies decide what will be done
  • Timer construct is a mechanism for ensuring CPU
    protection, but deciding how long the timer is
    set for a particular user is a policy decision
  • The separation of policy from mechanism is a very
    important principle, it allows maximum
    flexibility if policy decisions are to be changed
    later.

51
System Implementation
  • Traditionally written in assembly language, OS
    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
  • Is easier to port (move to some other hardware)

52
System Generation (SYSGEN)
  • OS are designed to run on any of a class of
    machines various sites, various peripheral
    configurations
  • The system must be configured for each specific
    computer site
  • System generation (SYSGEN)
  • SYSGEN program obtains information concerning the
    specific configuration of the hardware system
  • CPU (kind and number)
  • Memory size, available devices
  • OS options, parameter values (buffer size, max
    of processes)

53
System Generation (Cont.)
  • How to generate a system?
  • Recompile
  • Cause the creation of tables and selection of
    modules from a precompiled library
  • Link modules together to form the generated OS
  • SYSGEN is faster, but the generated OS may be
    overly general
  • Completed table driven
  • All the code is always part of the system, and
    selection occurs at execution time
  • Most modern OS are constructed in this manner
  • Size and generality of the generated system and
    the ease of modification as the hardware
    configuration changes

54
Booting
  • For a computer to start running
  • Booting starting a computer by loading the
    kernel
  • Bootstrap program the initial program
  • Code stored in ROM that is able to locate the
    kernel, load it into memory, and start its
    execution
  • Initialize all aspects of the system CPU
    registers, device controllers, memory contents
  • Two step process a simple bootstrap loader
    fetches a more complex boot program from disk,
    which in turn loads the kernel
  • PC, Sun Solaris
  • Section 14.3.2 and Appendix A
Write a Comment
User Comments (0)
About PowerShow.com