Introduction to Advanced Operating System

Embed Size (px)

Citation preview

  • 8/13/2019 Introduction to Advanced Operating System

    1/27

    Advanced Operating System

    M. Sc. Computer Science and Information Technology,Tribhuvan University

    By

    Bishnu Gautam

  • 8/13/2019 Introduction to Advanced Operating System

    2/27

    by Bishnu Gautam 2

    Objectives of the course

    Introduce the underlying principles of an

    operating system, virtual memory and resource

    management concepts. Exposer of current state of art research in

    operating system

    Exposure of distributed operating system, real-

    time operating system and multimedia systems.

    General OverviewAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    3/27

    by Bishnu Gautam 3

    Why Learn about Operating Systems?

    Tangible reasons

    Build or modify a real operating system

    Administer and use system well

    Tune application performance

    Intangibles reasons

    Intrinsic curiosity Understand how much of your computer system works

    Gain/apply knowledge in other areas of Computer Science Computer architecture and devices

    Synchronization in programming languages Data structures and algorithms

    Performance analysis

    Challenge of designing large, complex systems

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    4/27

    by Bishnu Gautam 4

    Course Overview1. Introduction -1week 2. Process, Memory and Storage Management -7weeks

    First Internal Examination

    3. System Protection and Security -2weeks4. Distributed Operating Systems, Distributed File

    Systems -3weeks

    5. Real-time Systems, Multimedia Systems -2weeks

    Second Internal Examination -15weeks

    Final Examination

    General OverviewAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    5/27

    by Bishnu Gautam 5

    Books and References

    Text Book:

    1. Silberschatz, Galvin and Gagne, Operating System Concepts, 8th

    Edition, John-Wiley.

    References :

    1. Research and Technical Papers

    2. Tanenbaum, A. S.,Modern Operating Systems, 3rd Edition, PHI

    3. Stallings, W., Operating Systems, Fourth Edition, Pearson.

    4. Tanenbaum, A. S. and Woodhull, A. S., Operating Systems Design andImplementation, Second Edition, PHI.

    Lab References:

    Linux Manual, Linux Programming Manual and C book.

    General OverviewAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    6/27

    by Bishnu Gautam 6

    Evaluation system

    Total mark (75) = Assessment (15) + Semester (60)

    Assessment marks is distributed as follows:

    Assignments (5) + Internal Examination1 (5) + Internal

    Examination2 (5) = 15

    Assignments are basically Lab works and Case Studies,

    each assignment will have a due date for submission and

    demonstration, it is mandatory to submit their report with

    in the due date. Home works will be assigned in class only for your

    practice, not for submission, but sometime it may assigned

    as an assignment.

    General OverviewAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    7/27

    by Bishnu Gautam 7

    Introduction Computer System Structure

    What is Operating Systems

    Operating-System Structure

    Operating-System Operations

    Process Management

    Memory Management

    Storage Management

    Protection and Security Distributed Systems

    Special-Purpose SystemsReading: Textbook Chapter 1 & 2

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    8/27

    by Bishnu Gautam 8

    Computer System Structure

    Computer system can be divided into four components:

    Hardware provides basic computing resources

    CPU, memory, I/O devices

    Operating system Controls and coordinates use of hardware among various applications

    and users

    Application programs define the ways in which the system

    resources are used to solve the computing problems of the users

    Word processors, compilers, web browsers, database systems, video

    games

    Users

    People, machines, other computers

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    9/27

    by Bishnu Gautam 9

    Computer System Structure

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    10/27

    by Bishnu Gautam 10

    What is an operating system?

    An operating system (OS) is a collection of system programs that

    together control the operation of a computer system.

    Operating system goals:

    Execute user programs and make solving user

    problems easier.

    Make the computer system convenient to use.

    Use the computer hardware in an efficient manner.

    Provides an environment within which other programs can do

    useful work.

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    11/27

    by Bishnu Gautam 11

    Two Functions of OS

    OS as an Extended Machine

    OS as a Resource Manager

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    12/27

    by Bishnu Gautam 12

    OS as an Extended MachineOS creates higher-level abstraction for programmer

    Example: (Floppy disk I/O operation)

    -disks contains a collection of named files

    -each file must be open for READ/WRITE

    -after READ/WRITE complete close that file

    -no any detail to dealOS shields the programmer from the disk hardware and presents a simple fileoriented interface.

    OS function is to present the user with the equivalent of an extendedmachine or virtual machine that is easier to program than the

    underlying hardware.Challenges:

    What are the right abstractions? How to achieve this?

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    13/27

    by Bishnu Gautam 13

    OS as a Resource Manager

    -What happens if three programs try to print their output on the sameprinter at the same time?

    -What happens if two network users try to update a shared document atsame time?

    OS primary function is to manage all pieces of a complex system.Advantages:

    Virtualizes resource so multiple users/applications can share

    Protect applications from one another

    Provide efficient and fair access to resourcesChallenges:

    What mechanisms? What policies?

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    14/27

    by Bishnu Gautam 14

    OS evolution

    Computer Generation, Component and OS Types

    1st (1945-55) Vacuum Tubes User Driven

    2nd (1955-65) Transistor Batch

    3rd (1965-80) IC Multiprogramming

    4th

    (1980-present) PC Client Server/Distributed

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    15/27

    by Bishnu Gautam 15

    Operating System Structure Multiprogramming:Multiple jobs in memory at the same time. Each memory

    space protected from each other. OS picks one, execute it for a while, stops (e.g.when programs reads for input or randomly), picks other to run.

    Needed for efficiency

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

    One job selected and run viajob scheduling When it has to wait (for I/O for example), OS switches to another job

    Timesharing (multitasking) is logical extension in which CPU switches jobsso frequently that users can interact with each job while it is running, creating

    interactive computing

    Response time should be < 1 second

    Each user has at least one program executing in memory process

    If several jobs ready to run at the same time CPU scheduling

    If processes dont fit in memory, swapping moves them in and out to run

    Virtual memory allows execution of processes not completely in memory

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    16/27

    by Bishnu Gautam 16

    Operating-System Operations

    OS must insure that an incorrect program can not cause otherprograms to execute incorrectly, and must terminate the sucherroneous program.

    Provide hardware support to differentiate between at least two modesof operations.

    1. User mode . execution done on behalf of a user.

    User programs runs in user mode, which permits only the subset ofinstructions to be executed and subset of features to be accessed.

    2. Kernel mode (or supervisor mode) . execution done on behalfof operating system.

    OS runs in kernel mode, giving it access to the complete hardware.

    Mode bit is added to the hardware of the computer to indicate thecurrent mode: kernel(0) and user(1).

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    17/27

    by Bishnu Gautam 17

    Dual-Mode OperationWhen an trap or interrupt occurs hardware switches from user modeto the kernel mode. Thus, whenever the OS gains control of computer,

    it is in kernel mode. The system always switches to user mode before

    passing control to the user program.

    Privileged instructions can be issued only in kernel mode.

    Advantages:

    protect OS from errant users and errant user from one another.

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    18/27

    by Bishnu Gautam 18

    Process Management

    A process is a program in execution. A process needs certainresources, including CPU time, memory, files, and I/O

    devices, to accomplish its task.

    The operating system is responsible for the following activitiesin connection with process management.

    Process creation and deletion.

    Process suspension and resumption.

    Provision of mechanisms for:

    process synchronization

    process communication

    deadlock handling

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    19/27

    by Bishnu Gautam 19

    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.

    The operating system is responsible for the followingactivities in connections with memory management:

    Keep track of which parts of memory are currently being used and

    by whom.

    Decide which processes to load when memory space becomesavailable.

    Allocate and deallocate memory space as needed.

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    20/27

    by Bishnu Gautam 20

    File Management

    A file is a collection of related information defined by its creator.

    Commonly, files represent programs (both source and object

    forms) and data.

    The operating system is responsible for the followingactivities in connections with file management:

    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.

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    21/27

    by Bishnu Gautam 21

    I/O Management

    All computers have physical devices for acquiring input

    and producing output.

    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.

    Disk management.

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    22/27

    by Bishnu Gautam 22

    Protection and SecuritySituation: a computer system has multiple users and allows theconcurrent execution of multiple processes, then access to data mustbe regulated.

    Required mechanisms that ensures files, memory segments, CPU, andother resources can be operated on by only those processes that have

    gained proper authorization from the operating system Protection mechanism for controlling access of processes or usersto resources defined by the OS

    Security defense of the system against internal and external attacks Huge range, including denial-of-service, worms, viruses, identity theft, theft of service

    Systems generally first distinguish among users, to determine who can

    do what User identities (user IDs, security IDs) include name and associated number User ID then associated with all files, processes of that user to determine access control Group identifier (group ID) allows set of users to be defined and controls managed Privilege escalation allows user to change to effective ID with more rights

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    23/27

    by Bishnu Gautam 23

    Distributed Systems

    A distributed system is a collection of physically separate, possibly

    heterogeneous, computer systems that are networked toprovide the users

    with access to the various resources that the system maintains.

    Access to a shared resource increases computation speed,functionality, data availability, and reliability

    Network Operating System provides features between systems across

    network

    Communication scheme allows systems to exchange messages Illusion of a single system

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    24/27

    by Bishnu Gautam 24

    Special-Purpose Systems

    The computer systems whose functions are more limited and whose

    objective is to deal with limited computation domains

    Real-time embedded systems most prevalent form of

    computers Vary considerable, special purpose, limited purpose OS, real-time OS

    Multimedia systems

    Streams of data must be delivered according to time restrictions

    Handheld systems PDAs, smart phones, limited CPU, memory, power

    Reduced feature set OS, limited I/O

    IntroductionAdvanced Operating System

  • 8/13/2019 Introduction to Advanced Operating System

    25/27

    by Bishnu Gautam 25

    System callsSystem calls provide the interface between a process and the operatingsystem. Typically 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)

    Example: ReadFile() function in the Win32 APIa function for reading from a file

    IntroductionAdvanced Operating System

    HANDLE filethe file to be readLPVOID buffera buffer where the datawill be read into and written fromDWORD bytesToReadthe number ofbytes to be read into the bufferLPDWORD bytesReadthe number ofbytes read during the last readLPOVERLAPPED ovlindicates ifoverlapped I/O is being used

  • 8/13/2019 Introduction to Advanced Operating System

    26/27

  • 8/13/2019 Introduction to Advanced Operating System

    27/27

    by Bishnu Gautam 27

    Home Works

    HW #1:

    1. Textbook: (Ch. 1) 1.1, 1.3, 1.4, 1.6, 1.7, 1.8, 1.13,1.19 & 1.21

    2. Textbook: (Ch. 2) 2.1, 2.2, 2.14, 2.8 & 2.19,

    2. What does the CPU do when there are no programs to run?3. What must user programs be prohibited from writing to the

    memory locations containing the interrupt vector?

    4. Classify the following applications as batch-oriented or interactive.

    a) Word processing

    b) Generating monthly bank statementsc) Computing pi to a million decimal places

    5. What is a purpose of system calls?

    IntroductionAdvanced Operating System