dhamdhere os2e chapter 02 powerpoint slides

73
Chapter 2: Overview of Operating Systems Dhamdhere: Operating Systems— A Concept-Based Approach , 2 ed Slide No: 1 Copyright © 2008 PROPRIETARY MATERIAL. © 2007 The McGraw-Hill Companies, Inc. All rights reserved. No part of this PowerPoint slide may be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual course preparation. If you are a student using this PowerPoint slide, you are using it without permission.

Upload: manjunath-maddy

Post on 03-Nov-2014

171 views

Category:

Documents


12 download

DESCRIPTION

operating system

TRANSCRIPT

Page 1: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 1Copyright © 2008

PROPRIETARY MATERIAL. © 2007 The McGraw-Hill Companies, Inc. All rights reserved. No part of this PowerPoint slide may be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual course preparation. If you are a student using this PowerPoint slide, you are using it without permission.

Page 2: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 2Copyright © 2008

Overview of operating systems

• A modern OS contains a very large number of features– Many of these features were first introduced in different classes

of operating systems, namely* Batch Processing operating systems

* Multiprogramming operating systems

* Time sharing operating systems

* Real time operating systems

* Distributed operating systems

– These features are used in a modern OS as well* We study these features in the context of the relevant OS

* Study their influence on system performance and user service

Page 3: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 3Copyright © 2008

Recap from Chapter 1

• The fundamental goals of an operating system– Obtain

* High system performance

* Good user service

within a computing environment

– A computing environment consists of a computer system, its interfaces with other systems, and user computations

* Measures of system performance and user service depend on the computing environment

Page 4: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 4Copyright © 2008

Recap from Chapter 1

• Fundamental tasks of an OS– Management of Programs

* Organize their execution by sharing the CPU

* Ensure good user service

– Management of Resources* Fast allocation and de-allocation without constraining user programs

* Efficient use of resources

– Security and Protection* Ensure absence of interference with programs and resources by

entities within and outside the OS

Page 5: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 5Copyright © 2008

Introduction

In this chapter, we shall first study:

• Fundamentals of OS operation– Features of a computer that are important for an OS

– How the OS controls execution of programs

– How a program interacts with an OS

• Efficiency, system performance and user convenience– Measures of system performance

– User service as a measure of user convenience

Page 6: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 6Copyright © 2008

OS and the Computer System

• In this module, we study– Fundamental features of computer systems that are important to

an OS* Memory hierarchy

* Interrupt structure

* I/O organization

– How an OS uses these features to control operation of an OS

– Fundamentals of how a program interacts with an OS

Page 7: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 7Copyright © 2008

Memory utilization during operation of an OS

• The kernel is the core of the OS; it is memory resident at all times• Non-kernel programs are loaded in the transient area when needed• Rest of the memory is shared between user programs

Page 8: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 8Copyright © 2008

Model of a computer system

• The CPU and the I/O subsystem have independent paths to memory• The memory management unit plays a part in implementing virtual memory

Page 9: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 9Copyright © 2008

The program status word (PSW)

• The CPU contains two kinds of registers– User accessible registers

* Used for arithmetic or logical operations, addressing, indexing, etc. These are called general purpose registers, or simply, CPU registers

– Control registers* Condition code register (also called the flags register), program

counter, etc.

* Their contents govern operation of the CPU

• Control registers are collectively called the program status word (PSW)– Individual control registers are considered as fields of the PSW

Page 10: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 10Copyright © 2008

Fields of the Program Status Word (PSW)

• The ‘privileged mode’ field indicates whether the CPU is in the privileged mode, which is used by the OS, or user mode * Some instructions can be executed only when CPU is in the privileged mode• Condition code and Program counter registers were mentioned before• Other registers are discussed later

Page 11: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 11Copyright © 2008

Privileged mode of CPU

• The CPU can operate in two modes. The privileged mode (P) field of PSW controls the CPU mode– Privileged mode (`P’ field contains 1)

* Certain sensitive instructions can be executed only when the CPU is in this mode

For example, initiation of an I/O operation, setting protection information for a program

These instructions are called privileged instructions

– User mode* Privileged instructions cannot be executed when the CPU is in this

mode

Page 12: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 12Copyright © 2008

State of the CPU

• The state of the CPU consists of– The PSW and contents of the general purpose registers of the

CPU

– It indicates* What the CPU is engaged in doing at any moment

* What the CPU can do, in terms of privileges to perform certain operations

– The OS keeps track of the state of the CPU to know what the program currently executing on the CPU is doing

Page 13: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 13Copyright © 2008

State of the CPU

(a) An assembly language program(b) CPU state of the program after executing the COMPARE instruction – 0 in the P field indicates that the CPU is in the user mode – 150 in the PC field indicates that the CPU is about to execute the instruction with address 150

Page 14: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 14Copyright © 2008

Memory hierarchy

• The memory hierarchy is a cost-effective method of obtaining a large and fast memory– It is an arrangement of several memories with different access

speeds and sizes* The CPU accesses only the fastest memory; i.e., the cache

* If a required byte is not present in the memory being accessed, it is loaded there from a slower memory

Page 15: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 15Copyright © 2008

Memory hierarchy

• Cache memory is the fastest and disk the slowest in the hierarchy• The CPU accesses only the cache memory• If required data or instruction is not present in the cache, it is loaded there from memory (if not present in memory, it is first loaded from disk)

Page 16: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 16Copyright © 2008

Memory hierarchy

• Cache memory– Organization

* A cache block or cache line is loaded from memory when some byte in it is referenced

* A ‘write-through’ arrangement is typically used to update memory

– The cache hit ratio (h) indicates what percentage of accessed bytes were already present in cache

* The cache hit ratio has high values because of Temporal locality Spatial locality

* Effective memory access time =

h x access time of cache memory +

(1 – h) x (time to load a cache block + access time of cache memory)

Page 17: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 17Copyright © 2008

Memory hierarchy

• Main memory– Memory protection prevents access to memory by an

unauthorized program* Memory bound registers indicate bounds of the memory allocated to

a program (see next slide)

• Virtual memory– The part of memory hierarchy consisting of the main memory

and a disk is called virtual memory* A program and its data are stored on the disk

* Required portions of the program and its data are loaded in memory when accessed

Page 18: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 18Copyright © 2008

Memory protection using bound registers

• The lower bound register (LBR) and upper bound register (UBR) contain addresses of first and last bytes allocated to the program• LBR, UBR are stored in the memory prot info (MPI) field of the PSW• The CPU raises an interrupt if an address is outside the LBR–UBR range

Page 19: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 19Copyright © 2008

Input / Output organization

• An I/O operation slows down a program’s execution due to mismatch of CPU and I/O speeds– Involvement of the CPU in I/O operations should be the

minimum possible * CPU should be free to execute instructions while I/O operations are

in progress

– Different I/O modes* Programmed I/O

* Interrupt I/O

* Direct memory access (DMA)

Page 20: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 20Copyright © 2008

Input / Output modes

• Details of the Input/output modes– Programmed I/O

* Data transfer between memory and an I/O device takes place through the CPU

CPU cannot perform any other operation until I/O completes

– Interrupt I/O* An I/O instruction starts an I/O operation and frees the CPU to

execute other instructions An interrupt is raised every time a unit of data is to be

transferred between memory and the I/O device An interrupt processing program in the kernel actually transfers

the data

Page 21: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 21Copyright © 2008

Input / Output modes

• Details of the Input/output modes (contd)– Direct memory access (DMA)

* An I/O instruction indicates the operation to be performed and the number of bytes of data to be transferred. Its execution starts the I/O operation

Data transfer is coordinated by the DMA controller; it does not involve the CPU

When the I/O operation completes, the DMA controller raises an I/O interrupt to indicate its completion (interrupts are discussed later)

CPU is free to execute other instructions while an I/O operation is in progress

Page 22: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 22Copyright © 2008

Interrupts

• An interrupt signals the occurrence of an event to the CPU – An event is a situation that requires OS intervention

– At an interrupt, the interrupt action in the hardware diverts the CPU to execution of an interrupt processing routine (IPR)

* The IPR is a routine in the OS kernel

* It handles the situation that caused the interrupt

* After the IPR, kernel switches the CPU to execution of a user program

– Different classes of interrupts convey occurrences of different kinds of events

Page 23: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 23Copyright © 2008

Classes of interrupts

• Three important classes of interrupts are– Program interrupt

* Caused by conditions within the CPU during execution of an instruction; e.g.,

Occurrence of an arithmetic overflow, addressing exception, or memory protection exception

Execution of the software interrupt instruction

– I/O interrupt* Indicates completion of an I/O operation

– Timer interrupt* Indicates that a specified time interval has elapsed

Page 24: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 24Copyright © 2008

The interrupt action

1. The interrupt code is formed depending on the cause of the interrupt; it is stored in the interrupt code (IC) field of the PSW2. The PSW is saved in a memory location (or in the stack)3. Contents of an appropriate interrupt vector are loaded in the PSW; new contents of the PSW now control CPU operation

Page 25: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 25Copyright © 2008

Steps in interrupt action

• The interrupt action consists of three steps1. Set interrupt code in the PSW

* The code describes the situation that caused the interrupt

* It is stored in the interrupt code field of the PSW

2. Save the PSW* PSW is saved in a memory location

* Interrupt code gets saved as a part of the PSW

3. Load interrupt vector* Interrupt vector of the occurred interrupt is chosen

It contains address of the interrupt processing routine (IPR)

* It is loaded in the PSW Control is transferred to the IPR

Page 26: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 26Copyright © 2008

Interrupt driven operation of a kernel

• At the occurrence of an interrupt, the CPU is diverted to the interrupt processing routine (IPR), which is a part of the kernel• The IPR handles the interrupt by performing appropriate actions• The IPR passes control to the scheduler, which selects a program for execution

Page 27: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 27Copyright © 2008

Servicing of an I/O interrupt and return to the same user program

User program→ IPR for I/O interrupt→ Scheduler→ User program

Page 28: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 28Copyright © 2008

Nested interrupts

• An interrupt may occur while a previous interrupt is being processed– The interrupt action would divert the CPU to handle the new

interrupt. On completion of its processing, processing of the previous interrupt would be resumed

* It may delay processing of the previous interrupt

– The interrupt mask (IM) indicates whether a new interrupt should be allowed to occur while a previous interrupt is being serviced

* Each bit in the mask controls masking of one class of interrupts If an interrupt is masked off: it remains pending If an interrupt is enabled: it can occur

Page 29: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 29Copyright © 2008

Simple and nested interrupt processing

(a) A single interrupt occurs and is serviced(b) A nested interrupt occurs. Processing of the previous interrupt is suspended until the new interrupt gets handled

Page 30: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 30Copyright © 2008

System Call

• A computer has a special instruction called a ‘software interrupt’ instruction– Its sole purpose is to cause a program interrupt

– Its operand becomes the interrupt code* A program uses the software interrupt instruction to make a request

to the system The operand of the instruction indicates what kind of request is

being made Association between interrupt code and kind of request is

OS-specific

* This method of making a request is known as a system call

Page 31: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 31Copyright © 2008

Types of system calls

• System calls are used to make diverse kinds of requests – Resource related

* Resource request or release, checking resource availability

– Program related* Execute or terminate a program, set or await timer interrupt

– File related* Open or close a file, read or write a record

– Information related* Get time and date, get resource information

– Communication related* Send or receive message, setup or terminate connection

Page 32: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 32Copyright © 2008

Efficiency, system performance and user convenience

• The nature of a computing environment determines– The nature of user computations

* Non-interactive computing environment Back-office applications

* Interactive computing environment Online applications

* Real time computing environment Time-critical applications

– Notions of efficiency, system performance and user service * e.g., user service is

Response time for interactive computing Deadline for real time computing

Page 33: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 33Copyright © 2008

Computations in an OS

• We discuss four kinds of computations in an OS– Program

* A set of functions or modules, including those from libraries

– Job* A sequence of job steps

Each job step is an execution of a program It is executed only if previous job steps executed successfully

– Process* A process is an execution of a program

– Subrequest* A subrequest is a computational requirement presented by a user to

a process. It produces a single response comprising of results or actions

Page 34: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 34Copyright © 2008

Measures of efficiency and user convenience

• We use the following measures– Efficiency of use

* CPU efficiency Percent utilization of CPU

– System performance* Throughput

Amount of work done per unit of time

– User service* Turn-around time

Time between submission and completion of a job or process

* Response time Time between issuing and completion of a subrequest

Page 35: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 35Copyright © 2008

Efficiency and user convenience in different OS classes

• Service is a user-centric consideration• Efficiency is a system-centric consideration• Different OSs trade them off differently

Page 36: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 36Copyright © 2008

Efficiency and user convenience in differentOS classes

• Explanation of the previous chart:– A multiprogramming OS provides better efficiency than a batch

processing OS because it services many processes in an overlapped manner

* However, user convenience does not change

– A time sharing system provides better response times than a multiprogrammed system

* Hence it provides the better user convenience

– A real time OS does not provide as much efficiency as a time sharing OS because it may reserve some resources for exclusive use of a process

Page 37: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 37Copyright © 2008

Batch processing system

In early operating systems, the computer operator had to

manually set-up execution of every job

• Aim of batch processing:– To reduce operator’s intervention in processing of user jobs

* A batch is a sequence of jobs

* The operator sets up processing of a batch, rather than processing of individual jobs

It saves valuable time spent in human actions

Page 38: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 38Copyright © 2008

Batch processing system

• The operator forms a batch of jobs and inserts ‘start of batch’ and ‘end of batch’ cards• Operator initiates processing of a batch• The batch monitor, which is a primitive OS, performs transition between individual jobs

Page 39: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 39Copyright © 2008

Turn-around time in a batch processing system

• ‘Turn-around time’ of a job is the time between the submission of a job and obtaining of its results • If results are printed after entire batch is processed, turn-around time depends on execution time of all jobs in the batch

Page 40: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 40Copyright © 2008

Batch processing

• Control statements are used to facilitate batch processing– Users insert control statements in their jobs to specify

* Start and end of a job, end of program or data* Requirements concerning execution of a program

– The batch monitor processes the control statements to take appropriate actions

* Initiate or terminate processing of a batch* Initiate or terminate processing of a job* Protect adjoining programs in the batch against interference

If a program tries to read more data than provided, the end-of- data card alerts the batch monitor

Batch monitor terminates the program (see next slide)

Page 41: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 41Copyright © 2008

Control statements in IBM 360/370 systems

• The // JOB and /& statements are start-of-job and end-of-job statements• The // EXEC statement indicates which program is to be executed• The /* card indicates end of the program or end of its data

Page 42: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 42Copyright © 2008

Multiprogramming Systems

In a batch processing system, the CPU remained idle while

a program performed I/O operations

• Aim of multiprogramming:– Achieve efficient use of the computer system through

overlapped execution of several programs* While a program is performing I/O operations, the OS schedules

another program

Page 43: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 43Copyright © 2008

Operation of a multiprogramming system

(a) Program 1 performs I/O and Program 2 executes on the CPU(b) Program 2 initiates I/O, so OS switches the CPU to Program 3(c) Program 1’s I/O operation completes, so OS switches CPU to its execution

Page 44: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 44Copyright © 2008

Architectural support for multiprogramming

• The computer’s architecture must contain following features to support multiprogramming– DMA

* To provide parallel operation of the CPU and I/O

– Interrupt hardware* To implement the interrupt action, which passes control to the OS

– Memory protection* To prevent corruption or disruption of a program by other programs

– Privileged mode of CPU* CPU must be in privileged mode to execute sensitive instructions

* It is in the user mode, i.e., non-privileged mode, while executing user programs

Page 45: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 45Copyright © 2008

Functions of a multiprogramming kernel

• The kernel of a multiprogramming OS performs the following functions– Resource allocation and protection

* It uses memory protection to avoid interference between programs

– Keeping track of start and end of I/O operations through interrupt processing, so that it can

* Initiate I/O operations

* Perform scheduling

Page 46: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 46Copyright © 2008

Concepts and techniques of multiprogramming

• Three key concepts are– Use a suitable program mix of CPU-bound and I/O-bound

programs* A CPU-bound program performs computations most of the time,

and I/O operations seldom* An I/O bound program performs I/O operations frequently

– Assign suitable priorities to programs* Decide which program should be favoured for execution on the CPU

—an I/O-bound program or a CPU-bound program?

– Use a suitably high degree of multiprogramming * Degree of multiprogramming = No of programs in memory* Facilitates parallel operation of CPU and I/O system

Page 47: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 47Copyright © 2008

Priority in a multiprogramming OS

• Priority is a tie-breaking rule used when more than one program is ready for execution– At any moment, the highest priority program that is not waiting

for an I/O operation to complete is chosen for execution

– Preemptive priority* Definition: Preemption is forcible removal of a program from the

CPU

* A low priority program executing on the CPU is preempted when a high priority program becomes ready for execution

Page 48: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 48Copyright © 2008

Program priority in Multiprogramming OSs

The priority assignment rule for achieving better performance:

“I/O bound programs should have higher priorities than

CPU bound programs”

We shall discuss different priority assignments to I/O-bound and CPU-bound programs, study their influence on performance, and conclude accordingly

Page 49: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 49Copyright © 2008

Timing chart when a CPU-bound program has higher priority

• At time 0, the CPU-bound program is selected for execution• It starts an I/O operation at t11, hence progiob is selected for execution• progcb is scheduled at t13 when its I/O operation completes

progiob: I/O-bound programprogcb : CPU-bound program

Page 50: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 50Copyright © 2008

A CPU-bound program has higher priority

• Observations– CPU utilization is reasonable

– I/O utilization is poor

– Periods of concurrent CPU and I/O activities are rare

Q: Can I/O utilization be improved?

A: No! Adding an I/O-bound program does not help much because it has a low priority

Page 51: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 51Copyright © 2008

Timing chart when an I/O bound program has higher priority

• progiob is selected at time 0• It starts an I/O operation at t21, hence progcb is scheduled• progcb is preempted when progiob’s I/O operation is completed

Page 52: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 52Copyright © 2008

An I/O-bound program has higher priority

• Observations:– CPU utilization is reasonable

– I/O utilization is reasonable

– Periods of concurrent CPU and I/O activities are frequent

Q: Can CPU and I/O utilization be improved?

A: Yes

* Addition of a CPU-bound program improves CPU utilization

* Addition of an I/O-bound program improves I/O utilization

Page 53: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 53Copyright © 2008

Performance and user service in multiprogramming

– Performance is measured as throughput * Throughput is the number of programs serviced by the system in a

unit of time

* For high throughput, I/O-bound programs should have higher priorities than CPU-bound programs

– User service is measured as turn-around time of a job* Turn-around time of a job is the elapsed time between submission

of a job and its completion

Page 54: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 54Copyright © 2008

Improving throughput in a multiprogramming system

• How to improve throughput?– Add a CPU-bound program, give it the lowest priority

* It uses the CPU when it would have been idle, e.g., the interval t26-t27

* Its presence does not affect progress made by other programs

– Add an I/O-bound program, give it a high priority* Its presence improves I/O utilization

* It may affect progress of the CPU-bound program marginally

Page 55: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 55Copyright © 2008

Variation of throughput with degree of multiprogramming

Q: Why does the throughput stagnate at high values of m?

Page 56: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 56Copyright © 2008

Time sharing systems

• In interactive computing, users desire good response times to their subrequests– Response time to a subrequest is the time since the subrequest

is made to the time its results are obtained

– A time sharing system provides good response times to subrequests through

* Round-robin processing of programs

* Using a time slice (δ) to prevent a program from using too much CPU time in one go

Page 57: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 57Copyright © 2008

A schematic of round-robin scheduling with time slicing

• The OS maintains a list of programs that wish to execute on the CPU• The scheduler selects the first program in the list• If the time slice elapses before the scheduled program completes its operation, it is preempted and put back into the scheduling list

Page 58: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 58Copyright © 2008

Operation of a time slicing scheduler

(a) The program is preempted when the time slice elapses; i.e., after it has consumed δ seconds(b) The program gives up the CPU when it starts an I/O operation; i.e., before it has consumed δ seconds; another program is now scheduled

Page 59: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 59Copyright © 2008

Time sharing systems

• Relation between time slice and response time– Choice of the time slice depends on two factors

* Response time to programs

* Overhead of switching between programs (σ)

– If every program consumes δ CPU seconds before producing a response,

* response time is = na x (δ + σ), where na is the number of active programs

* CPU efficiency is = δ / (δ+σ)

Page 60: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 60Copyright © 2008

Choice of δ

• Influence of δ on response time– If δ is very small

* A program may need more CPU time than δ to satisfy a request Hence a program may have to be scheduled several times

before a response can be obtained

* Efficiency is low if δ and σ are comparable

* Cache performance may be poor

– If δ is large

* Response time would be better than na x ( δ+σ )

* Efficiency would be better than δ / (δ+σ) because programs may not use the complete time slice

Page 61: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 61Copyright © 2008

Swapping

• Swapping is the technique of moving inactive programs out of the memory temporarily– It increases the number of programs that can be processed by

the time sharing system

Q: What are the conditions under which swapping is most effective?

Page 62: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 62Copyright © 2008

A schematic of swapping

• The OS swaps out a program that is not likely to be executed immediately in future; it frees the memory occupied by the program• It swaps in a new program in the newly freed memory• The swapped-out program is loaded back before its turn for execution

Page 63: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 63Copyright © 2008

Real time Operating system

• A real time OS is used to service time critical applications– A time critical application is one that malfunctions if it does not

receive a ‘timely response’* Timeliness of the response depends on the nature of the application

* A real time OS focuses on providing a timely response to an application

Page 64: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 64Copyright © 2008

Real time Operating system

• Two kinds of real time operating systems– Hard real time system: Meets the response requirement of an

application under all conditions (including error recovery actions, if any)

* Used in command and control applications

* A computer system may have to be dedicated to an application

– Soft real time system: Meets the response requirement of an application in a probabilistic manner

* Used in applications such as multimedia and reservation systems

Page 65: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 65Copyright © 2008

Real time operating systems

• Features of a real time OS– Permits creation of multiple processes within an application

* Overlapped operation of processes speeds up the application

– Permits priorities to be assigned to processes

– Permits a programmer to define interrupts in an application’s domain and provide interrupt processing routines

* Enables the application to respond readily to events

– Uses priority driven or deadline oriented scheduling* Helps in meeting the application’s time constraints

– Provides fault tolerance and graceful degradation* Such that essential services can be performed in a timely manner

Page 66: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 66Copyright © 2008

A satellite data logging application

• A satellite sends data to an earth station periodically– A computer application in the earth station receives the data

* The computer stores the data in the signal in a file

* Storing of data should be completed before the next signal arrives

Page 67: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 67Copyright © 2008

Tasks in the satellite data logging application

• Process 1 copies the data• Process 2 writes the data into a file• Process 3 performs statistical analysis on the data

Page 68: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 68Copyright © 2008

Distributed operating system

• Definition: a distributed computer system– A distributed computer system consists of a number of computer

systems, each having its own memory and performing some of the control functions of the OS, interacting through the network

– Each computer system is called a host or node, and the place where it is located is called a site

Page 69: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 69Copyright © 2008

A distributed system

• A WAN connects geographically distant nodes• A LAN connects nodes within an office, laboratory or building

Page 70: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 70Copyright © 2008

Distributed systems

• Benefits of a distributed system– Resource sharing

* An application can use resources located in other computers

– Reliability* Provides availability of resources despite faults

– Computation speed-up* Parts of a computation can be executed simultaneously in different

computers

– Communication* Users in different computer systems can communicate

– Incremental growth* Cost of enhancing capabilities of a system is proportional to the

desired enhancement

Page 71: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 71Copyright © 2008

Features of Distributed Operating Systems

• Parts of a distributed operating system execute in different nodes of a distributed system. Its salient features are:– The OS provides support for distributed computations

* Remote procedure call (RPC)

* Distributed file systems

– The OS uses distributed control techniques because* Several computers participate in a decision

* Control data may be distributed across nodes in the system

Page 72: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 72Copyright © 2008

Classical OS concepts in Modern OSs

• A modern OS supports different kinds of users, hence it has to fulfill diverse requirements– It uses many (most?) of the classical concepts discussed so far

to meet different requirements* We will see details of these in the next slide

– It uses adaptive techniques so that it can select the techniques that best suit a specific program

* This way it can handle diverse workloads effectively

Page 73: Dhamdhere OS2E Chapter 02 PowerPoint Slides

Chapter 2: Overview of Operating Systems

Dhamdhere: Operating Systems—A Concept-Based Approach , 2 ed

Slide No: 73Copyright © 2008

Classical OS concepts in Modern OSs

• A modern OS uses the following classical concepts– Batch processing concepts

* Database queries and back-office processing are batched

– Priority-based preemptive scheduling* To provide better service to high priority applications* To obtain efficient use of resources

– Time slicing * To provide good response times

– Swapping * To increase the number of processes serviced

– Creating multiple processes in an application* To provide timely response to real time applications

– Resource sharing across boundaries of computers