Operating System Principles - PowerPoint PPT Presentation

1 / 76
About This Presentation
Title:

Operating System Principles

Description:

Title: Operating System Principles Author: IBM Last modified by: IBM Created Date: 10/1/2006 5:05:53 PM Document presentation format: – PowerPoint PPT presentation

Number of Views:138
Avg rating:3.0/5.0
Slides: 77
Provided by: IBM62
Category:

less

Transcript and Presenter's Notes

Title: Operating System Principles


1
Operating SystemPrinciples
  • Ku-Yaw Chang
  • canseco_at_mail.dyu.edu.tw
  • Assistant Professor, Department of Computer
    Science and Information Engineering
  • Da-Yeh University

2
Chapter 2 System Structures
  • An operating system can be viewed from different
    vantage points
  • Services that the system provides
  • Programmers
  • Interface available to users and programmers
  • Users
  • Components and their connections
  • Operating system designer

3
Chapter 2 Computer System Structures
  1. Operating-System Services
  2. User Operating-System Interface
  3. System Calls
  4. Types of System Calls
  5. System Programs
  6. Operating-System Design and Implementation
  1. Operating-System Structure
  2. Virtual Machines
  3. Operating-System Generation
  4. System Boot
  5. Summary
  6. Exercises

4
2.1 Operating-System Services
  • Common services (1/2)
  • User interfaces
  • Command-line interface (CLI)
  • Batch interface
  • Graphical user interface (GUI)
  • Program execution
  • to load a program into memory and to run it.
  • I/O operations
  • user programs cannot execute I/O operations
    directly

5
2.1 Operating-System Services
  • Common services (1/2)
  • File-system manipulation
  • capability to read, write, create, and delete
    files
  • Communications
  • exchange of information between processes
  • Implemented via shared memory or message passing
  • Error detection
  • ensure correct computing by detecting errors in
    the CPU and memory hardware, in I/O devices, or
    in user programs

6
Additional Functions
  • Not for helping the user, but rather for ensuring
    efficient system operations
  • Resource allocation
  • allocate 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 and security
  • ensure that all access to system resources is
    controlled
  • each user authenticate himself or herself to the
    system

7
Chapter 2 Computer System Structures
  1. Operating-System Services
  2. User Operating-System Interface
  3. System Calls
  4. Types of System Calls
  5. System Programs
  6. Operating-System Design and Implementation
  1. Operating-System Structure
  2. Virtual Machines
  3. Operating-System Generation
  4. System Boot
  5. Summary
  6. Exercises

8
User Operating-System Interface
  • Two approaches for users to interact with OS
  • Command-line interface (CLI) or command
    interpreter
  • Graphical user interface (GUI)

9
2.2.1 Command Interpreter
  • Command interpreter
  • Included in the OS kernel
  • Treated as a special program
  • Windows XP and UNIX
  • Also known as shells
  • Multiple command interpreters to choose from
  • On UNIX and Linux systems
  • Bourne shell
  • C shell
  • See what was my login shell?
  • saturn echo SHELL
  • /bin/csh
  • Bourne-Again shell
  • Korn shell

10
2.2.1 Command Interpreter
  • Main function
  • To get and execute the next user-specified
    command
  • Example file manipulation
  • create, delete, list, print, copy, execute
  • Internal vs. external command
  • Internal
  • The command interpreter contains the code to
    execute the command
  • External
  • Use the command to identify a file to be loaded
    into memory and executed

11
2.2.2 Graphical User Interfaces
  • User-friendly desktop metaphor interface
  • A mouse-based window-and-menu system
  • Usually mouse, keyboard, and monitor
  • Icons represent files, programs, actions, etc
  • Various mouse buttons over objects in the
    interface cause various actions (provide
    information, options, execute function, open
    directory (known as a folder)
  • Invented at Xerox PARC

12
2.2.2 Graphical User Interfaces
  • Many systems now include both CLI and GUI
    interfaces
  • Microsoft Windows is GUI with CLI command shell
  • command.com or cmd.exe
  • Apple Mac OS X as Aqua GUI interface with UNIX
    kernel underneath and shells available
  • Solaris is CLI with optional GUI interfaces (Java
    Desktop, KDE)

13
Chapter 2 Computer System Structures
  1. Operating-System Services
  2. User Operating-System Interface
  3. System Calls
  4. Types of System Calls
  5. System Programs
  6. Operating-System Design and Implementation
  1. Operating-System Structure
  2. Virtual Machines
  3. Operating-System Generation
  4. System Boot
  5. Summary
  6. Exercises

14
2.3 System Calls
  • The interface between a process and the OS
  • Assembly-language
  • Higher-level language
  • C, C and Perl
  • Mostly accessed by programs via a high-level
    Application Program Interface (API) rather than
    direct system call use
  • Win32 API for Windows
  • POSIX API for POSIX-based systems (including
    virtually all versions of UNIX, Linux, and Mac OS
    X)
  • Java API for the Java virtual machine (JVM)

15
2.3 System Calls
  • Why use APIs rather than system calls?
  • Better program portability
  • Easy to work with

16
Depiction of XP Architecture
17
Different Types of I/O
  • Low-level I/O (system call)
  • _open, _close
  • _read, _write
  • Stream I/O
  • fopen, fclose
  • fread, fwrite
  • WIN32 API
  • CreateFile, CloseHandle
  • ReadFile, WriteFile

18
Example of Standard API
  • Consider the ReadFile() function in the Win32 API
  • a function for reading from a file
  • A description of the parameters passed to
    ReadFile()
  • HANDLE filethe file to be read
  • LPVOID buffera buffer where the data will be
    read into and written from
  • DWORD bytesToReadthe number of bytes to be read
    into the buffer
  • LPDWORD bytesReadthe number of bytes read during
    the last read
  • LPOVERLAPPED ovlindicates if overlapped I/O is
    being used

19
2.3 System Calls
  • Even simple programs may make heavy use of the
    operating system.
  • To read data from one file and to copy them to
    another file
  • Requiring a sequence of system calls
  • Details are hidden from the programmer

20
System Call Sequence
21
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)

22
The Handling of open() System Call
23
Standard C Library Example
  • C program invoking printf() library call, which
    calls write() system call

24
System Call Parameter Passing
  • 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

25
Parameter Passing via Table
26
Chapter 2 Computer System Structures
  1. Operating-System Services
  2. User Operating-System Interface
  3. System Calls
  4. Types of System Calls
  5. System Programs
  6. Operating-System Design and Implementation
  1. Operating-System Structure
  2. Virtual Machines
  3. Operating-System Generation
  4. System Boot
  5. Summary
  6. Exercises

27
2.4 Types of System Calls
  • Five major categories
  • Process control
  • File management
  • Device management
  • Information maintenance
  • Communications

28
2.4.1 Process Control
  • A running program
  • Halt its execution
  • normally (end)
  • abnormally (abort)
  • A dump of memory
  • Load and execute another program
  • fork()
  • exec()

29
MS-DOS
At System Start-up
Running a Program
30
FreeBSD running multiple programs
31
2.4.5 Communication
  • Two common models
  • Message-passing
  • Messages can be exchanged either directly or
    indirectly through a common mailbox
  • A connection must be established
  • open, connection, close
  • Useful for smaller amounts of data
  • Easier for intercomputer communication
  • Shared-memory
  • Create and gain access to regions of memory owned
    by other processes
  • Maximum speed and convenience

32
2.4.5 Communication
Message Passing
Shared Memory
33
Chapter 2 Computer System Structures
  1. Operating-System Services
  2. User Operating-System Interface
  3. System Calls
  4. Types of System Calls
  5. System Programs
  6. Operating-System Design and Implementation
  1. Operating-System Structure
  2. Virtual Machines
  3. Operating-System Generation
  4. System Boot
  5. Summary
  6. Exercises

34
2.5 System Programs
  • System programs provide a convenient environment
    for program development and execution
  • File management
  • Status information
  • File modification
  • Programming language support
  • Program loading and execution
  • Communication
  • System utilities or application programs
  • To solve common problems, or perform common
    operations
  • Web browsers and word processors
  • Games

35
2.5 System Programs
  • Command interpreter
  • The most important system program
  • Two approaches
  • The command interpreter contains the code to
    execute the command.
  • Internal command
  • Implement most commands by system programs
  • External command

36
Chapter 2 Computer System Structures
  1. Operating-System Services
  2. User Operating-System Interface
  3. System Calls
  4. Types of System Calls
  5. System Programs
  6. Operating-System Design and Implementation
  1. Operating-System Structure
  2. Virtual Machines
  3. Operating-System Generation
  4. System Boot
  5. Summary
  6. Exercises

37
2.6.1 Design Goals
  • User goals
  • should be convenient to use, easy to learn,
    reliable, safe, and fast
  • System goals
  • should be easy to design, implement, and
    maintain, as well as flexible, reliable,
    error-free, and efficient

38
2.6.2 Mechanisms and Policies
  • General software engineering principles are
    applicable to operating systems
  • Separation of policy from mechanism
  • For flexibility
  • Mechanisms
  • How to do something
  • A general mechanism
  • Policies
  • What will be done
  • Change across places or over time

39
2.6.2 Mechanisms and Policies
  • Microkernel-based
  • Take the separation of mechanism and policy to
    one extreme
  • Windows / Apple Macintosh (Mac OS X)
  • Both mechanism and policy are encoded in the
    system

40
2.6.3 Implementation
  • Traditionally written in assembly language,
    operating systems can now be written in
    higher-level languages such as C/C
  • Linux and Windows XP are written mostly in C
  • Code written in a high-level language
  • can be written faster
  • more compact
  • easier to understand and debug
  • easier to port (move to some other hardware)
  • Disadvantage
  • Reduced speed and increased storage requirements

41
Chapter 2 Computer System Structures
  1. Operating-System Services
  2. User Operating-System Interface
  3. System Calls
  4. Types of System Calls
  5. System Programs
  6. Operating-System Design and Implementation
  1. Operating-System Structure
  2. Virtual Machines
  3. Operating-System Generation
  4. System Boot
  5. Summary
  6. Exercises

42
2.7 Operating-System Structure
  • To partition the task (OS) into small components
    (modules)
  • Not one monolithic system
  • Available approaches
  • Simple structure
  • Layered approach
  • Microkernels
  • Modules

43
2.7.1 Simple Structure
  • MS-DOS
  • written to provide the most functionality in the
    least space
  • not divided into modules
  • Although having some structure, its interfaces
    and levels of functionality are not well separated

44
MS-DOS Layer Structure
45
2.7.1 Simple Structure
  • UNIX (original)
  • consists of two separable parts
  • Kernel
  • everything below the system-call interface and
    above the physical hardware
  • System programs

46
Unix System Structure
47
2.7.2 Layered Approach
  • OS is broken into a number of layers (or levels)
  • Each built on top of lower layers
  • The bottom layer (layer 0) is the hardware
  • The highest layer (layer N) is the user interface
  • With modularity, layers are selected such that
    each uses functions (operations) and services of
    only lower-level layers.
  • Simplify debugging and system verification
  • Difficult to define each layer
  • Less efficient overhead

48
A Layered OS
49
An OS layer
50
OS/2 layer structure
51
Windows NT
  • First release
  • A highly layer-oriented organization
  • Low performance (compared to Windows 95)
  • NT 4.0
  • Move layers from user space to kernel space
  • Closely integration

52
2.7.3 Microkernels
  • Mach
  • Developed at Carnegie Mellon University in the
    mid-1980s
  • Use the microkernel approach
  • Removing non-essential components from the kernel
  • Implement them as system- and user-level programs
  • A smaller kernel
  • Main function
  • To provide a communication facility

53
2.7.3 Microkernels
  • Benefits
  • easier to extend
  • easier to port
  • more security
  • more reliability
  • Examples
  • Tru64 UNIX UNIX Mach kernel
  • MacOS X based on Mach kernel
  • QNX a real-time OS
  • Windows NT ( a hybrid structure)

54
Windows NT client-server structure
55
2.7.4 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

56
Solaris Loadable Modules
57
Chapter 2 Computer System Structures
  1. Operating-System Services
  2. User Operating-System Interface
  3. System Calls
  4. Types of System Calls
  5. System Programs
  6. Operating-System Design and Implementation
  1. Operating-System Structure
  2. Virtual Machines
  3. Operating-System Generation
  4. System Boot
  5. Summary
  6. Exercises

58
2.8 Virtual Machines
  • A computer system is made up of layers
  • Hardware is the lowest
  • Virtual machines
  • take the layered approach to its logical
    conclusion
  • treat hardware and the operating system kernel as
    though they were all hardware
  • provide an interface identical to the underlying
    bare hardware
  • OS creates the illusion of multiple processes
  • each has on its own processor with its own
    (virtual) memory

59
System Models
Non-virtual Machine
Virtual Machine
60
2.8.1 Implementation
  • Difficult to implement
  • To provide an exact duplicate of the underlying
    machine
  • User mode
  • Monitor mode
  • Time the major difference
  • I/O
  • Less time or more time
  • CPU
  • Multiprogrammed among many virtual machines

61
2.8.2 Benefits
  • Provide complete protection of system resources
  • Each virtual machine is isolated from all other
    virtual machines.
  • Permits no direct sharing of resources
  • 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
  • Solve system compatibility problems

62
2.8.3 Examples
  • 2.8.3.1 VMware
  • a popular commercial application
  • abstract Intel 80X86 hardware
  • run several guest operating systems concurrently

63
VMware Architecture
64
2.8.3.2 Java Virtual Machine
  • A very popular object-oriented language
  • By Sun Microsystems in late 1995
  • Consists of
  • A language specification
  • A large API library
  • A specification for a Java virtual machine (JVM)
  • A class loader
  • A class verifier
  • A Java interpreter

65
2.8.3.2 Java Virtual Machine
  • A Java program consists of one or more classes.
  • For each class, the Java compiler produce an
    architecture-neutral bytecode output (.class)
    file
  • Run on any implementation of the JVM

66
Java virtual machine
67
2.8.3.2 Java Virtual Machine
  • Garbage collection
  • Reclaim memory from objects no longer in use and
    return it to the system
  • Just-in-time (JIT) compiler
  • The first time a Java method is invoked, the
    bytecodes are turned into native machine language
    for the host computer
  • These operations are cached for later use

68
Chapter 2 Computer System Structures
  1. Operating-System Services
  2. User Operating-System Interface
  3. System Calls
  4. Types of System Calls
  5. System Programs
  6. Operating-System Design and Implementation
  1. Operating-System Structure
  2. Virtual Machines
  3. Operating-System Generation
  4. System Boot
  5. Summary
  6. Exercises

69
2.9 Operating System Generation
  • Operating systems are designed to run on any of a
    class of machines
  • must be configured for each specific computer
    site.
  • System generation (SYSGEN)
  • obtain information concerning the specific
    configuration of the hardware system.
  • from a given file
  • ask the operator
  • probe the hardware directly

70
Chapter 2 Computer System Structures
  1. Operating-System Services
  2. User Operating-System Interface
  3. System Calls
  4. Types of System Calls
  5. System Programs
  6. Operating-System Design and Implementation
  1. Operating-System Structure
  2. Virtual Machines
  3. Operating-System Generation
  4. System Boot
  5. Summary
  6. Exercises

71
2.10 System Boot
  • Booting
  • starting a computer by loading the kernel
  • Bootstrap program (bootstrap loader)
  • code stored in ROM that is able to locate the
    kernel, load it into memory, and start its
    execution
  • two-step process
  • A simple bootstrap loader fetches a more complex
    boot program from disk

72
Chapter 2 Computer System Structures
  1. Operating-System Services
  2. User Operating-System Interface
  3. System Calls
  4. Types of System Calls
  5. System Programs
  6. Operating-System Design and Implementation
  1. Operating-System Structure
  2. Virtual Machines
  3. Operating-System Generation
  4. System Boot
  5. Summary
  6. Exercises

73
Summary
  • P.68 P.69

74
Chapter 2 Computer System Structures
  1. Operating-System Services
  2. User Operating-System Interface
  3. System Calls
  4. Types of System Calls
  5. System Programs
  6. Operating-System Design and Implementation
  1. Operating-System Structure
  2. Virtual Machines
  3. Operating-System Generation
  4. System Boot
  5. Summary
  6. Exercises

75
Exercises
  • 2.5
  • 2.6
  • 2.9
  • 2.10

76
The End
Write a Comment
User Comments (0)
About PowerShow.com