Operating System 3 Dec 2013

download Operating System 3 Dec 2013

of 31

Transcript of Operating System 3 Dec 2013

  • 8/13/2019 Operating System 3 Dec 2013

    1/31

    Valia Koonambaikulathamma College of Engineering & Technology

    Department of Computer Science & Engineering

    08.406 OPERATING SYSTEMS

    MODULE I

    Q. What is an Operating System?

    An Operating System (OS) is an intermediary between users and computerhardware.

    It provides users an environment in which a user can execute programsconveniently and efficiently.

    In technical terms, It is a software which manages hardware. An operating System controls the allocation of resources and services such as

    Memory management Process management, Devices management, Security, Network management, File Management Control over system performance, Job accounting, Error detecting aids Coordination between other software and users Information management.

  • 8/13/2019 Operating System 3 Dec 2013

    2/31

    Q. What are the main operating system services?

    An Operating System provides services to both the users and to the programs.

    It provides programs, an environment to execute.

    It provides users, services to execute the programs in a convenient manner.

    Following are few common services provided by operating systems.

    Program execution I/O operations File System manipulation Communication Error Detection Resource Allocation Protection

    Program execution

    Loads program into memory. Executes the program. Handles program's

    execution

    Provides a mechanism for process synchronization Provides a mechanism for process communication. Provides a mechanism for deadlock handling.

    I/O Operation

    I/O operation means read or write operation with any file or any specific I/Odevice.

    Program may require any I/O device while running. Operating system provides the access to the required I/O device when required.

    File system manipulation

    Program needs to read a file or write a file.

  • 8/13/2019 Operating System 3 Dec 2013

    3/31

    The operating system gives the permission to the program for operation onfile.

    Permission varies from read-only, read-write, denied and so on. Operating System provides an interface to the user to create/delete files. Operating System provides an interface to the user to create/delete

    directories.

    Operating System provides an interface to create the backup of filesystem.

    Communication

    Two processes often require data to be transferred between them. The both processes can be on the one computer or on different computer

    but are connected through computer network.

    Communication may be implemented by two methods either by Shared Memoryor by Message Passing.

    Error handling

    OS constantly remains aware of possible errors. OS takes the appropriate action to ensure correct and consistent computing.

    Resource Management

    OS manages all kind of resources using schedulers. CPU scheduling algorithms are used for better utilization of CPU.

    Protection

    OS ensures that all access to system resources is controlled. OS ensures that external I/O devices are protected from invalid access attempts. OS provides authentication feature for each user by means of a

    password.

  • 8/13/2019 Operating System 3 Dec 2013

    4/31

    Q. What are the three main purposes of an operating system?

    Answer:

    To provide an environment for a computer user to execute programs on computerhardware in a convenient and efficient manner.

    To allocate the separate resources of the computer as needed to solve the problemgiven. The allocation process should be as fair and efficient as possible.

    As a control program it serves two major functions: (1) supervision of theexecution of user programs to prevent errors and improper use of the computer,

    and (2) management of the operation and control of I/O devices.

    Q. What are the main differences between operating systems for mainframe

    computers and personal computers?

    Generally, operating systems for batch systems have simpler requirements thanfor personal computers.

    Batch systems do not have to be concerned with interacting with a user asmuch as a personal computer.

    As a result, an operating system for a PC must be concerned with response timefor an interactive user.

    Batch systems do not have such requirements. A pure batch system also mayhave not to handle time sharing, whereas an operating system must switch rapidly

    between different jobs.

    Q. List the four steps that are necessary to run a program on a completely dedicated

    machine?

    Reserve machine time. Manually load program into memory. Load starting address and begin execution. Monitor and control execution of program from console.

    Q. Early Systems

    Early computers were physically massive machines run from a console.

  • 8/13/2019 Operating System 3 Dec 2013

    5/31

    The programmer, of the computer system, would write a program and then would operatethe program directly from the operators console.

    First, the program would be loaded manually into memory from the front panel switches(one instruction at a time), from paper tape, or from punched cards.

    Then, the appropriate buttons would be pushed to set the starting address and to start theexecution of the program.

    As the program ran, the programmer could monitor its execution by the display lights onthe console.

    If errors were discovered, the programmer could halt the program, examine the contentsof memory and registers, and debug the program directly from the console.

    Output was printed or was punched onto paper tape or cards for later printing

    Structure of Early Systems

    Single user system. Programmer/User as operator (Open Shop). Large machines run from console. Paper Tape or Punched cards.

    Characteristics of Early Systems

  • 8/13/2019 Operating System 3 Dec 2013

    6/31

    Early software: Assemblers, Libraries of common subroutines (I/O, Floating-point),Device Drivers, Compilers, Linkers.

    Need significant amount of setup time. Extremely slow I/O devices. Very low CPU utilization. But computer was very secure.

    1. Dedicated Computer Systems Later, additional software and hardware were developed. Assemblers, loaders, and

    linkers were designed to ease to programming task. Libraries of common functions

    were created. Common functions could then be copied into a new program without

    having to be written again, providing software reusability.

    The routines that performed I/O were especially important. Each new I/O device hadits own characteristics. A special subroutinecalled a device driverwas written

    for each I/O device.

    A device driver knows how the buffers, flags, registers, control bits, and statusbitsfor a particular device should be used. Each type of device has its own driver.

    Later, compilers for FORTRAN, COBOL, and other languages appeared, making theprogramming task much easier but the operation of the computer more complex.

    2. Shared Computer Systems When a job stopped, the Operator would have to notice that it had stopped (by

    observing the console), determine why its topped (normal or abnormal termination),

    dump memory and register (if necessary), load the appropriate device with the next

    job, and restart the computer. During this transition from one job to the next, the CPU

    sat idle.

    To overcome this idle time, people developed automatic job sequencing; with thistechnique, the first basic operating systems were created.

  • 8/13/2019 Operating System 3 Dec 2013

    7/31

    A small program, called a resident monitor (Job Sequencer), was created totransfer control automatically from one job to the next. The resident monitor is

    always in memory (or resident).

    When the computer was turned on, the resident monitor was invoked, and it wouldtransfer control to a program.

    When the program terminated, it would return control to the resident monitor, whichwould then go on to the next program. Thus, the resident monitor would automatically

    sequence from one program to another and from one job to another.

    Parts of resident monitor:o Control card Interpreterresponsible for reading and carrying out instructions on

    the cards.

    o Loaderloads systems programs and applications programs into memory.o Device drivers know special characteristics and properties for each of the

    systems I/O devices.

    3. Overlapped I/ O

  • 8/13/2019 Operating System 3 Dec 2013

    8/31

    One common solution to the I/O problem was to replace slow card readers (input devices)and line printers (output devices)with magnetic-tape units.

    The majority of computer systems in the late1950s and early1960s were batch systemsreading from card readers and writing to line printers or card punches.

    Rather than have the CP U read directly from cards, however, the cards were first copiedonto a magnetic tape via a separate device. When the tape was sufficiently full, it was

    taken down and carried over to the computer.

    When a card was needed for input to a program, the equivalent record was read from thetape. Similarly, output was written to the tape, and the contents of the tape were printed

    later.

    The card readers and line printers were operated off-line, rather than the main computer

    An obvious advantageof off-line operation was that the main computer was no longerconstrained by the speed of the card readers and line printers but was limited only by the

    speed of the much faster magnetic tape units.

    The technique of using magnetic tape for all I/O could be applied with any similarequipment

    The real gain in off-line operation is the using of multiple reader-to-tape and tape-to-printer systems for one CPU. If the CPU can process input twice as fast as the readercan read cards, then two readers working simultaneously can produce enough tape to

    keep the CPU busy.

  • 8/13/2019 Operating System 3 Dec 2013

    9/31

    There is some disadvantage too,a longer delay in getting a particular job run. The jobmust first be read onto tape. Then it must wait until enough additional jobs are read onto

    the tape to "fill" it.

    o Card reader, Line printer and Tape drives slow (compared to Disk).o I/O and CPU could not overlap

    Solution: Spooling -o Overlap I/O of one job with the computation of another job (using double

    buffering, DMA, etc).

    o Technique is called SPOOLing: Simultaneous Peripheral Operation On Line

    SPOOLing System Components

    While executing one job, the Operating System: Reads next job from card reader into astorage area on the disk (Job pool) and Outputs printout of previous job from disk to

    printer.

  • 8/13/2019 Operating System 3 Dec 2013

    10/31

    Job poolis a data structure that allows the OS to select which job to run next in order toincrease CPU utilization.

    Q. Evolution of Operating Systems?

    Early Systems (1950) Simple Batch Systems (1960) Multiprogrammed Batch Systems (1970) Time-Sharing and Real-Time Systems (1970) Personal/Desktop Computers (1980) Multiprocessor Systems (1980) Networked/Distributed Systems (1980) Web-based Systems (1990)

    Q. Discuss the Concept of Operating-System Structures?

    Common System Components Operating System Services System Calls System Programs System Structure Virtual Machines System Design and Implementation System Generation

    1. Common System Components Process Management Main Memory Management

  • 8/13/2019 Operating System 3 Dec 2013

    11/31

    File Management I/O System Management Secondary Management Networking Protection System Command-Interpreter System

    a. Process Management A process is a program in execution. A process needs certain resources,

    including CPU time, memory, files, and I/O devices, to accomplish its task.

    The operating system is responsible for the following activities inconnection with process management.

    o Process creation and deletion.o Process suspension and resumption.o Provision of mechanisms for:

    process synchronization process communication

    b. 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 The operating system is responsible for the following activities

    o Keep track of which parts of memory are currently being used and bywhom.

    o Decide which processes to load when memory space becomesavailable.

    o Allocate and deallocate memory space as needed.c. File Management

    A file is a collection of related information defined by its creator. The operating system is responsible for the following activities

    o File creation and deletion.o Directory creation and deletion.o Support of primitives for manipulating files and directories.o Mapping files onto secondary storage.

  • 8/13/2019 Operating System 3 Dec 2013

    12/31

    o File backup on stable (nonvolatile) storage media.d. I/O System Management

    The I/O system consists ofo A buffer-caching systemo A general device-driver interfaceo Drivers for specific hardware devices

    e. Secondary-Storage Management Since main memory (primary storage) is volatile and too small to

    accommodate all data and programs permanently, the computer system

    must provide secondary storage to back up main memory.

    Most modern computer systems use disks as the principle on-line storagemedium, for both programs and data

    The operating system is responsible for the following activities inconnection with disk management:

    o Free space managemento Storage allocationo Disk scheduling

    f. 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 communicationnetwork. Communication takes place using a protocol.

    A distributed system provides user access to various system resources. Accessto a shared resource allows:

    o Computation speed-upo Increased data availabilityo Enhanced reliability

    g. 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:o distinguish between authorized and unauthorized usage.

  • 8/13/2019 Operating System 3 Dec 2013

    13/31

    o specify the controls to be imposed.o provide a means of enforcement.

    h. Command-Interpreter System Many commands are given to the operating system by control statements

    which deal with

    o process creation and managemento I/O handlingo secondary-storage managemento main-memory managemento file-system accesso protectiono networking

    The program that reads and interprets control statements is called variously:o command-line interpretero shell (in UNIX)

    2. Operating System Services. Program executionsystem 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 performs it.

    File-system manipulation program capability to read, write, create, anddelete files.

    Communications exchange of information between processes executingeither on the same computer or on different systems. Implemented via

    shared memory or message passing.

    Error detectionensure correct computing by detecting errors in the CPUand memory hardware, in I/O devices, or in user programs.

    a. Additional Operating System Functions Resource allocationallocating resources to multiple users or multiple jobs

    running at the same time.

  • 8/13/2019 Operating System 3 Dec 2013

    14/31

    Accounting keep track of and record which users use how much and whatkinds of computer resources for account billing or for accumulating usage

    statistics.

    Protectionensuring that all access to system resources is controlled3. System Calls

    System calls provide the interface between a running program and theoperating system.

    o Generally available as assembly-language instructions.o Languages defined to replace assembly language for systems

    programming allow system calls to be made directly (e.g., C, C++)

    Three general methods are used to pass parameters between a runningprogram and the operating system.

    o Pass parameters in registers.o Store the parameters in a table in memory, and the table address is

    passed as a parameter in a register.

    o Push (store) the parameters onto the stack by the program, and popoff the stack by operating system.

    Passing of Parameters As A Table

    Types of System Callso Process controlo File management

  • 8/13/2019 Operating System 3 Dec 2013

    15/31

    o Device managemento Information maintenanceo Communications

    Communication Modelso Communication may take place using either message passing or shared

    memory.

    4. System Programs System programs provide a convenient environment for program

    development and execution. They can be divided into:

    o File manipulationo Status informationo File modificationo Programming language supporto Program loading and executiono Communicationso Application programs

    5. System Structure MS-DOS Layer Structure

  • 8/13/2019 Operating System 3 Dec 2013

    16/31

    UNIX System Structure

    Layered Approacho 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.

    o With modularity, layers are selected such that each uses functions(operations) and services of only lower level layers.

    o An Operating System Layer

  • 8/13/2019 Operating System 3 Dec 2013

    17/31

    o OS/2 Layer Structure

    o Windows NT Client-Server Structure

  • 8/13/2019 Operating System 3 Dec 2013

    18/31

    Q. What is the main difficulty that a programmer must overcome in writing an

    operating system for a real-time environment?

    The main difficulty is keeping the operating system within the fixed timeconstraints of a real-time system.

    If the system does not complete a task in a certain time frame, it may cause abreakdown of the entire system it is running. Therefore when writing anoperating system for a real-time system, the writer must be sure that his

    scheduling schemes dont allow response time to exceed the time constraint

    Q. What is the purpose of system programs?

    System programs can be thought of as bundles of useful system calls. Theyprovide basic functionality to users so that users do not need to write their own

    programs to solve common problems.

    Q. What is the main advantage of the layered approach to system design? What are

    the disadvantages of using the layered approach?

    As in all cases of modular design, designing an operating system in a modularway has several advantages.

    The system is easier to debug and modify because changes affect only limitedsections of the system rather than touching all sections of the operating system.

    Information is kept only where it is needed and is accessible only within adefined and restricted area, so any bugs affecting that data must be limited to a

    specific module or layer.

    Q. What is the purpose of system calls?

    System calls allow user-level processes to request services of the operatingsystem.

  • 8/13/2019 Operating System 3 Dec 2013

    19/31

    System calls allow user-level processes to request services of the operatingsystem.

    Q. What is the purpose of the command interpreter? Why is it usually separate

    from the kernel?

    It reads commands from the user or from a file of commands and executes them,usually by turning them into one or more system calls.

    It is usually not part of the kernel since the command interpreter is subject tochanges.

    Q.What are the three major activities of an operating system in regard to memorymanagement?

    Keep track of which parts of memory are currently being used and by whom. Decide which processes are to be loaded into memory when memory space

    becomes available.

    Allocate and deallocate memory space as needed.Q. What are the five major activities of an operating system in regard to process

    management?

    The creation and deletion of both user and system processes The suspension and resumption of processes The provision of mechanisms for process synchronization The provision of mechanisms for process communication The provision of mechanisms for deadlock handling

    Q. What are the three major activities of an operating system in regard to

    secondary-storage management?

    Free-space management. Storage allocation. Disk scheduling.

    Q. List five services provided by an operating system. Explain how each provides

    convenience to the users?

  • 8/13/2019 Operating System 3 Dec 2013

    20/31

    Program execution. The operating system loads the contents (or sections) of afile into memory and begins its execution. A user level program could not be

    trusted to properly allocate CPU time.

    I/O operations. Disks, tapes, serial lines, and other devices must becommunicated with at a very low level. The user need only specify the device and

    the operation to perform on it, while the system converts that request into device-

    or controller-specific commands. User-level programs cannot be trusted to access

    only devices they should have access to and to access them only when they are

    otherwise unused.

    File-system manipulation. There are many details in file creation, deletion,allocation, and naming that users should not have to perform. Blocks of disk

    space are used by files and must be tracked.Deleting a file requires removing the

    name file information and freeing the allocated blocks. Protections must also be

    checked to assure proper file access. User programs could neither ensure

    adherence to protection methods nor be trusted to allocate only free blocks anddeallocate blocks on file deletion.

    Communications. Message passing between systems requires messages to beturned into packets of information, sent to the network controller, transmitted

    across a communications medium, and reassembled by the destination system.

    Packet ordering and data correction must take place. Again, user programs might

    not coordinate access to the network device, or they might receive packets

    destined for other processes.

    Error detection. Error detection occurs at both the hardware and softwarelevels. At the hardware level, all data transfers must be inspected to ensure that

    data have not been corrupted in transit. All data on media must be checked to be

    sure they have not changed since they were written to the media. At the software

    level, media must be checked for data consistency; for instance, whether the

    number of allocated and unallocated blocks of storage matches the total number

    on the device. There, errors are frequently process-independent, so there must be

    a global program (the operating system) that handles all types of errors. Also, by

    having errors processed by the operating system, processes need not contain code

    to catch and correct all the errors possible on a system.

    Types of Operating System

    http://ecomputernotes.com/fundamental/disk-operating-system/types-of-operating-systemhttp://ecomputernotes.com/fundamental/disk-operating-system/types-of-operating-systemhttp://ecomputernotes.com/fundamental/disk-operating-system/types-of-operating-systemhttp://ecomputernotes.com/fundamental/disk-operating-system/types-of-operating-system
  • 8/13/2019 Operating System 3 Dec 2013

    21/31

    There are Many Operating Systems which have the Capability to Perform the

    Requests those are received from the System. The Operating system can perform a

    Single Operation and also Multiple Operations at a Time.

    Serial Processing:

    o The Serial Processing Operating Systems are those which Performs

    all the instructions into a Sequence Manner or will be executed by

    using the FIFO Manner means First in First Out.

    o All the Instructions those are Entered First in the System will be

    Executed

    First and the Instructions those are Entered Later Will be

    Executed Later.

    o For Running the Instructions the Program Counter is used which is

    used for

  • 8/13/2019 Operating System 3 Dec 2013

    22/31

    o In this the Program Counter will determines which instruction is going to

    Execute and the which instruction will be Execute after this.

    o Mainly the Punch Cards are used for this. In this all the Jobs are firstly

    Prepared and Stored on the Card and after that card will be entered in the

    System and after that all the Instructions will be executed one by One.

    o But the Main Problem is that a user doesnt interact with the System

    Batch Processing

    o The Batch Processing is same as the Serial Processing Technique.

    o But in the Batch Processing Similar Types of jobs are Firstly Prepared and

    they are Stored on the Card. and that card will be Submit to the System for

    the Processing.

    o The System then Perform all the Operations on the Instructions one by one.

    And a user cant be Able to specify any input.

    o And Operating System wills increments his Program Counter for Executing

    the Next Instruction.

    o The Main Problem is that the Jobs those are prepared for Execution

    must be the Same Type and if a job requires for any type of Input then this

    will not be Possible for the user.

    o The Batch Contains the Jobs and all those jobs will be executed without the

    user Intervention.

    o And Operating System will use the LOAD and RUN Operation. This will

    first LOAD the Job from the Card and after that he will execute the

    instructions. By using the RUN Command.

    o The Speed of the Processing the Job will be Depend on the Jobs and the

    http://ecomputernotes.com/fundamental/disk-operating-system/what-is-operating-systemhttp://ecomputernotes.com/fundamental/disk-operating-system/what-is-operating-systemhttp://ecomputernotes.com/fundamental/disk-operating-system/what-is-operating-systemhttp://ecomputernotes.com/fundamental/disk-operating-system/what-is-operating-system
  • 8/13/2019 Operating System 3 Dec 2013

    23/31

    Results those are produced by the system

    o

    Time-sharing operating systems

    o Time sharing is a technique which enables many people, located at various

    terminals, to use a particular computer system at the same time.

    o Time-sharing or multitasking is a logical extension of multiprogramming.

  • 8/13/2019 Operating System 3 Dec 2013

    24/31

    o Processor's time which is shared among multiple users simultaneously is

    termed as time-sharing.

    o The main difference between Multiprogrammed Batch Systems and Time-

    Sharing Systems is that in case of Multiprogrammed batch systems, objectiveis to maximize processor use, whereas in Time-Sharing Systems objective is

    to minimize response time.

    Advantages of Timesharing operating systems are following

    Provide advantage of quick

    response. Avoids duplication of

    software.

    Reduces CPU idle time.

    Disadvantages of Timesharing operating systems are following.

    Problem of reliability.

    Question of security and integrity of user programs and data.

    Problem of data communication.

    Distributed operating System

    o Distributed systems use multiple central processors to serve multiple real time

    application and multiple users.

    o Data processing jobs are distributed among the processors accordingly to which

    one can perform each job most efficiently.

    o The processors communicate with one another through various communication

    lines (such as high-speed buses or telephone lines).

    o These are referred as loosely coupled systems or distributed systems.

  • 8/13/2019 Operating System 3 Dec 2013

    25/31

    o Processors in a distributed system may vary in size and function.

    The advantages of distributed systems are following.

    With resource sharing facility user at one site may be able to use the

    resources available at another.

    Speedup the exchange of data with one another via electronic mail.

  • 8/13/2019 Operating System 3 Dec 2013

    26/31

    If one site fails in a distributed system, the remaining sites can

    potentially continue operating.

    Better service to the customers.

    Reduction of the load on the host computer.Reduction of delays in data processing.

    Network operating System

    o Network Operating System runs on a server and provides server the capability to

    manage data, users, groups, security, applications, and other networking functions.

    o The primary purpose of the network operating system is to allow shared file

    and printer access among multiple computers in a network, typically a local area

    network (LAN), a private network or to other networks.

    o Examples of network operating systems are Microsoft Windows Server 2003,

    Microsoft Windows Server 2008, UNIX, Linux, Mac OS X, Novell NetWare, and BSD.

    The advantages of network operating systems are following.

    Centralized servers are highly

    stable. Security is server managed.

    Upgrades to new technologies and hardwares can be easily integrated into the

    system.

    Remote access to servers is possible from different locations and types of systems.

    The disadvantages of network operating systems are following.

    High cost of buying and running a server.

  • 8/13/2019 Operating System 3 Dec 2013

    27/31

    Dependency on a central location for most

    operations. Regular maintenance and updates are

    required.

    Real Time operating System

    o Real time system is defines as a data processing system in which the time

    interval required to process and respond to inputs is so small that it controls the

    environment.

  • 8/13/2019 Operating System 3 Dec 2013

    28/31

    [CSE VKCET] Page 28

    o Real time processing is always on line whereas on line system need not be

    real time.

    o The time taken by the system to respond to an input and display of required

    updated information is termed as response time. So in this method response

    time is very less as compared to the online processing.

    o Real-time operating system has well-defined, fixed time constraints otherwise

    system will fail. For example Scientific experiments, medical imaging systems,

    industrial control systems, weapon systems, robots, and home-appliance

    controllers, Air traffic control system etc.

    o There are two types of real-time operating systems.

    o Hard real-time systems

    o Hard real-time systems guarantee that critical tasks complete on time. In hardreal- time systems secondary storage is limited or missing with data stored inROM. In these systems virtual memory is almost never found.

    o Soft real-time systems

    o Soft real time systems are less restrictive. Critical real-time task gets priorityover other tasks and retains the priority until it completes. Soft real-timesystems have limited utility than hard real-time systems. For example,Multimedia, virtual reality, Advanced Scientific Projects like underseaexploration and planetary rovers etc.

  • 8/13/2019 Operating System 3 Dec 2013

    29/31

    [CSE VKCET] Page 29

  • 8/13/2019 Operating System 3 Dec 2013

    30/31

    [CSE VKCET] Page 30

    Q. What is preemptive and non preemptive scheduling?

    Tasks are usually assigned with priorities. At times it is necessary to run a certain taskthat has a higher priority before another task although it is running. Therefore, therunning task is interrupted for some time and resumed later when the priority task has

    finished its execution. This is called preemptive scheduling. With pre-emptive CPU

    scheduling, a new process can run when interrupt occurs.

    E.g.: Round robin

  • 8/13/2019 Operating System 3 Dec 2013

    31/31

    In non-preemptive scheduling, a running task is executed till completion. It cannot beinterrupted.

    E.g. First In First Out

    Q.