chapter 1 basic concepts of operating systems. 2 software a program is a sequence of instructions...

71
Chapter 1 Basic Concepts of Operating Systems

Upload: scarlett-gregory

Post on 13-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

Chapter 1Basic Concepts of Operating Systems

Page 2: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

2

Software• A program is a sequence of instructions that

enables the computer to carry out some specific task.

• Before a program executes, it has to be translated from its original text form (source program/code) into a machine language program (object program/code). Then, the program needs to be linked and loaded into memory.

Page 3: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

3

Software Components

• The software components are the collection of programs that execute in the computer.

• These programs perform computations, control, manage, and carry out other important tasks.

• Two general types of software components are:– System software– Application software

Page 4: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

4

System Software• The system software is the set of programs that

control the activities and functions of the various hardware components, programming tools and abstractions, and other utilities to monitor the state of the computer system.

• The system software forms an environment for the programmers to develop and execute their programs (collectively known as application software).

• Three types of users can be identified: system programmers, application programmers and end-users.

Page 5: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

5

Application Software• Application software are the user programs and

consist of those programs that solve specific problems for the users and execute under the control of the operating system. – Application programs are developed by individuals

and organizations 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

Page 6: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

Computer System Structure• Computer system can be divided into four components:

– Hardware – provides basic computing resources• CPU, memory, I/O devices• System software - Operating System, Assemblers, Loaders,

Linkers, Compilers, Editors, …– Operating system

• Controls and coordinates use of hardware among various applications and users

– Application programs – All User-Oriented Programs, which 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

Page 7: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

7

Computer System Structure

• System software - Operating System, Assemblers, Loaders, Linkers, Compilers, Editors, …

• Application software - All User-Oriented Programs.

SYSTEM and APPLICATION PROGRAMS

SYSTEM PROGRAMS/OS

HARDWARE

Users

Page 8: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

Operating System Definition (Cont.)• No universally accepted definition• “Everything a vendor ships when you order an

operating system” is a good approximation– But varies wildly

• “The one program running at all times on the computer” is the kernel.

• Everything else is either– a system program (ships with the operating

system) , or– an application program.

Page 9: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

9

External View of a Computer

Kernel

Page 10: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

10

What is an Operating System?• A large and complex set of software component

for the operation and control of the computer system. Availability of services and Management of the computer resources

• OS is a resource allocator– Manages all resources– Decides between conflicting requests for efficient and

fair resource use

• OS is a control program– Controls execution of programs to prevent errors and

improper use of the computer

• It acts as an intermediary between a user and the computer system.

Page 11: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

11

Design Goals

• User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast.

• System goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient.

Page 12: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

What Operating Systems Do• Depends on the point of view• Users want convenience, ease of use and good

performance – Don’t care about resource utilization– But shared computer such as mainframe or minicomputer

must keep all users happy

• Users of dedicate systems such as workstations have dedicated resources but frequently use shared resources from servers

• Handheld computers are resource poor, optimized for usability and battery life

• Some computers have little or no user interface, such as embedded computers in devices and automobiles

Page 13: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

13

Operating Systems User Interfaces

User and application programmers can communicate with OS via interface

Three levels of interface:

1. Graphical User Interface: GUI (windows oriented)

2. Command line level interpreter (also known as the shell). At login time, the shell starts computing

3. System calls interface invoked from user programs

Page 14: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

14

Basic Structure of an OSThe GUI and the Shell are at the same level in the structure of an OS

The GUI and the Shell are at the same level in the structure of an OS

Page 15: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

GUI

• The first and the highest level of is the GUI• Allow interaction via icons, menu, and other

graphical objects• This level of OS interface is not considered as

essential part of the Operating System, it is rather an add-on system software component.

Page 16: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

16

The Shell

• The second level of interface, the command line interpreter, or Shell program that handles user interaction with the system is called:– Shell– Command-line interpreter

• Two types of Shells– Graphical– Character oriented

Page 17: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

17

System Calls

• The third level, the System –call interface, is used by the application programs to request services provided by the OS by invoking or calling system functions. This is also known as the Application Programming Interface (API)

• Programs use the API to request the OS to perform some function

Page 18: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

Common Functions of Interrupts• Interrupt transfers control to the interrupt

service routine generally, through the interrupt vector, which contains the addresses of all the service routines

• Interrupt architecture must save the address of the interrupted instruction

• A trap or exception is a software-generated interrupt caused either by an error or a user request

• An operating system is interrupt driven

Page 19: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

Interrupt Handling• The operating system preserves the state of the

CPU by storing registers and the program counter

• Determines which type of interrupt has occurred:– polling– vectored interrupt system

• Separate segments of code determine what action should be taken for each type of interrupt

Page 20: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

Interrupt Timeline

Page 21: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

21

Multi-Level Views• The overall structure of an operating system is

divided into the various software components using a top-down (layered) approach.

• The top layer provides the easiest interface to the human operators and users interacting with the system.

• Any layer uses the services or functions provided by the next lower layer.

Page 22: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

22

Operating Systems Abstract Views

• External views (Sometimes refer to as the abstract views)

– Abstraction provides by the OS interfaces gives users and application programs the appearance of a simpler machine.

– Set of interface of the computer system– A layer of software on top of the hardware

• Internal view – System call interface separates the kernel from the

application layer – Resource manager - It controls and manages CPU,

memory, I/O devices, etc.

Page 23: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

23

Abstract Views of an OS

Page 24: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

Transition from User to Kernel Mode• Timer to prevent infinite loop / process hogging resources

– Timer is set to interrupt the computer after some time period– Keep a counter that is decremented by the physical clock.– Operating system set the counter (privileged instruction)– When counter zero generate an interrupt– Set up before scheduling process to regain control or

terminate program that exceeds allotted time

Page 25: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

25

Layered Structure of an OS

• Users (top layer)• Application User Interface (AUI): shell,

commands, application programs• Application program Interface (API): libraries,

system calls• OS kernel

Page 26: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

26

Internal View of an Operating System

• The system call interface separates the kernel from the application layer and the kernel is located above the hardware

• The kernel is the core and most critical part of the operating system and needs to be always resident in memory.

• A detailed knowledge about the different components, including these lower-level components of the operating system, correspond to an internal view of the system.

Page 27: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

27

Functional Components of an OS

The most important components of an operating system are:

• Process manager• Memory manager• Resource manager• File manager• Device manager

Page 28: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

28

Services Provided by the OS• Process Control, execution, scheduling, etc.

• Communication between processes

• File Manipulation

• Device Manipulation

• Information Maintenance

• Memory Management

Page 29: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

29

Jobs and ProcessesA job is a unit of work submitted by a user to the

operating system. A typical job consists of the parts listed below:

• A sequence of commands to the operating system• A program either in a source language or in binary

form• A set of input data used by the program when it

executes

A process basically refers to an execution instance of a program.

Page 30: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

30

Categories of Operating Systems• Batch systems, in which a set of jobs are submitted in

sequence for processing. The system have long average turnaround period (interval from job arrival time to completion time) of jobs.

• Interactive systems, which support computing for on-line users. The most common type of operating systems that support interactive computing is time-sharing, which are multi-user systems.

• Real-time systems, which support application programs with very tight timing constraints.

• Hybrid systems, which support batch and interactive computing.

Page 31: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

31

A Time-Sharing System

Page 32: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

Jobs

• The term job refers to a unit of work submitted by a user to the operating system.

• A typical job consist of the following:– A sequence of commands to the OS– A program either in a source language or in binary

form– A set of input data used by the program when it

executes

Page 33: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

33

History of Operating Systems• First generation - No operating system, bare

hardware, machine language.

• Second generation

– Batch systems, assemblers, linkers, loaders, compilers

– Batch systems with Automatic Job Sequencing

Page 34: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

34

History of Operating Systems(2)

• Third generation -- O.S. for complete families of computers (OS/360)

– Batch with Multiprogramming

– Spooling

– Timesharing (MULTICS, UNIX, …)

• Fourth generation

– Network and distributed operating systems

Page 35: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

35

Modern Operating Systems• Windows (Microsoft Corporation) these include a family of

systems: 98, Me, CE, 2000, XP, Vista, Windows 7, and others• Linux (Linus Torvalds, OSF GNU)• MacOS (Apple)• Solaris (Sun Microsystems)• OSF-1 (OSF, DEC)• IRIX (Silicon Graphics)• OS2 (IBM)• OS/390 (IBM)• VMS (Dec/Compaq/HP)

Page 36: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

36

System Implementation

• Traditionally written in assembly language, operating systems can now be written in higher-level languages.

• Code written in a high-level language:– can be written faster.– is more compact.– is easier to understand and debug.

• An operating system is far easier to port (move to some other hardware) if it is written in a high-level language.

Page 37: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

Chapter 2Processes and

Threads

Page 38: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

38

Processes & Threads

• Processes and threads are two important types of dynamic entities in computer system.

• A Process is a the execution of a Program; More specifically…– A process is a program in memory either

• in execution• waiting for CPU, I/O, or other service.

Page 39: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

Process Management• A process can contain one or more threads of

execution in order to execute, partially is waiting for other services in the computer system.

• An important function of the OS are:– It involves creating processes and controlling their

execution– The OS manages several processes in memory at

the same time – The processes share the system resources ---

multiprogramming39

Page 40: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

40

Processes• Two important types of dynamic entities in a computer

system are processes and threads. • The state changes are really controlled by the OS• When the process is needs a resources and is NOT

available, the processes changes from one state of changes from the running state to the waiting for resource state

• Then a process is waiting for service from the CPU, it is placed in the ready queue and is in the ready state.

• Also, when a process is waiting in I/O service, it is placed in one of several I/O queue and it changes to wait state.

Page 41: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

41

Process Creation• On a typical operating system, a process is

created– In response to a new job arriving– A new user who carries out a login– A currently executing process that creates a new

process.

• A process is created if there is sufficient memory available, and the process waits if other resources it needs are not available.

Page 42: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

42

Process Behavior

• A process requests CPU and I/O processing at various times and usually will have to wait for these services.

• The OS maintains a waiting line or queue of processes for every one of these services.

• At some point in time, the process will be in a queue waiting for CPU service. At some other point in time, the process will be in a different queue waiting for I/O service.

• When the process completes all service requests, it terminates and exits the system.

Page 43: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

43

Process States• Created• Ready (waiting in the ready queue for the CPU)• Running (executing)• Blocked (suspended and waiting for I/O or other event)• I/O processing• Waiting for passive resources• Interrupted by the OS• Terminated

Page 44: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

44

Process State Diagram

• Represents the various states of a process and the possible transitions in the behavior of a process.

• Each state is indicated by a rounded rectangle and the arrows connecting the states are the transitions from one state to the next.

• The small black circle denotes that the state it points to is the initial state.

• In a similar manner, the state before the hollow small circle indicates that it is the last state in the behavior of a process.

• Normally a process spends a short finite time in any of its states.

Page 45: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

45

Process State-Transition Diagram

Initial State

Last State

Process is ready and waits for CPU services

Process is created. In a time-sharing system, user logs New process is created.

The state in which a program is waiting for I/O service is normally called the block state

After satisfying all service requests, the process terminates

It is possible wait state is defined when the process is swapped out to disk, if there is not sufficient memory.

Page 46: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

46

Process Descriptor• Fro every new process in the system, a data

structure called Process Descriptor, also known as a process control block (PCB)

• The behavior of this process is that when the process terminates, its descriptor is normally destroyed.

Page 47: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

47

Data in a Process Descriptor

Each process is represented by its own PCB– Process name

– Process state

– Program counter, CPU registers

– I/O status

– Memory information

– Accounting information

– Scheduler information (priority, queues, …)

– List of resources

Page 48: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

48

Process Descriptor

Page 49: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

49

Threads• Modern OS supports computational units called threads.• A process can have multiple threads or sequences of

executions.• Threads often called:

– A light-weight process – A single execution sequence– A component of a process– Shares with other threads code and resources allocated to the

process– Most OSs support multi-threading: several threads in a single

process

Page 50: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

50

MultiThreading• In addition to multiple processes, newer operating

systems support other computational units called threads.

• A thread is called a lightweight process and is a dynamic component of a process.

• The OS manages processes and threads in a multiprogramming environment.

Page 51: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

51

Threads Executing in a Process

Threads behaves as a active elements of computation within a process. All threads that belong to a program share the code and resources of the process

Page 52: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

52

Thread Attributes

• The thread identifier uniquely identifies the threads. Its attributes are as follow:– Execution state– Context, its own program counter within the

process– Execution stack– Local memory block (for local variables)– Reference to parent process to access the shared

resources allocated to the process

Page 53: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

53

Thread Descriptor• A thread descriptor is a data structure used by the

OS to store all the relevant data of a thread. – It contains the following fields:

• thread identifier• execution state of the thread• the process owner of the thread• list of related threads• execution stack• thread priority• thread-specific resources

• Some of the fields of a thread descriptor also appear as part of the corresponding process descriptor.

Page 54: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

54

Thread States

• Threads have their own execution state, context, execution stack, local memory (for local variables), in addition to the resources allocated to the process.

• When a process is created, only one thread is created called the base thread of the process; then other threads of the process may be created by the process or by the base thread.

• A process can have a single thread; in this case it is considered a simple process because it has only one thread of execution.

Page 55: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

55

Types of Threads

There are two general types of threads:• User-level threads (ULT) – the threads

management is carried out at the application level without kernel innervation.

• Kernel-level threads (KLT). the threads management is carried out by kernel.

Page 56: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

56

User-level Threads• With the user-level threads, the thread

management is carried out at the level of the application without kernel intervention.

• The application carries out threads management using a thread library, such as the POSIX Pthreads Library.

• Using this library, the application invokes the appropriate functions for the various thread management tasks such as: creating, suspending, and terminating threads.

Page 57: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

57

Kernel-Level Threads • The thread management tasks are carried out

by the kernel. • A process that needs these thread handling

services has to use the API to the kernel thread facility.

• One of the advantages of kernel-level threads is that the process will not be blocked if one of its threads becomes blocked. Another advantage is that the possibility of scheduling multiple threads on multiple CPUs.

Page 58: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

Java Threads

• A program can have multiple execution paths (Sequences of flow of control) call threads.

• A typical Java application has multiple threads• A thread in Java is an object• Java provides several techniques to create and

manipulate threads

58

Page 59: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

POSIX Threads• Are known as Pthreads, is not object

oriented.• Developed for the C programming language• With C and C++, Pthreads is used as an

external library that needs to be linked with the application.

• The Psim3 (process simulation 3) package is used to implement the simulation model discussed in this book, that was developed with Pthreads.

59

Page 60: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

60

Multi-programming• OS can support several processes in memory through a

facility know as multiprogramming. • One of the requirements of multiprogramming is that the

OS must allocate the CPU and other resources to the various processes in such a way that the CPU and other active resources are maintained busy the longest period possible.

• If there is only one CPU in the computer system, then only one process can be in execution at any given time.

• The other processes are ready, waiting for CPU service. Processes also request access to passive resources, such as memory.

Page 61: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

61

Context Switch

• When the CPU switches to another process, the OS must save the state of the current process and load the saved state of the new process

• Context switch time is overhead time• Context switch time is dependent on

hardware support

Page 62: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

62

Degree of Multiprogramming

• An operating system can support several processes in memory.

• While one process receives service from the CPU, another process receives service from an I/O device and the other processes are waiting in some queues.

• The number of processes that the system supports is called the degree of multiprogramming.

Page 63: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

63

Features Needed for Multiprogramming

• I/O routines supplied by the system• Memory management• CPU scheduling• Allocation of devices

Page 64: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

Computing Environments• Allows operating systems to run applications within other OSes

– Vast and growing industry• Emulation used when source CPU type different from target

type (i.e. PowerPC to Intel x86)– Generally slowest method– When computer language not compiled to native code –

Interpretation• Virtualization – OS natively compiled for CPU, running guest

OSes also natively compiled – Consider VMware running WinXP guests, each running

applications, all on native WinXP host OS– VMM (virtual machine Manager) provides virtualization

services

Page 65: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

Computing Environments

• Use cases involve laptops and desktops running multiple OSes for exploration or compatibility– Apple laptop running Mac OS X host, Windows as a guest– Developing apps for multiple OSes without having multiple

systems– QA testing applications without having multiple systems– Executing and managing compute environments within data

centers• VMM can run natively, in which case they are also the host

– There is no general purpose host then (VMware ESX and Citrix XenServer)

Page 66: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

Computing Environments

Page 67: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

67

Service Demands

• A process will require several CPU and I/O requests (demands)

• The total CPU request of a process is divided into shorter service periods: each one is called a CPU burst

• The total I/O request is divided into shorter service periods called I/O bursts

• In normal behavior of a process, it alternates between a CPU and I/O burst

Page 68: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

68

Total I/O Service Demand

• The total I/O service demand for a process is the sum of all its I/O bursts

• Each I/O burst has a different duration, • The total I/O service time requested by

process Pi is:

i = 1 + 2 + ... n

Page 69: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

69

Batch OS with I/O

Page 70: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

70

Interrupts and Context Switches

A context switch occurs when:• The running process completes its current CPU burst

and needs an I/O operation, such as reading data from a file.

• The running process is interrupted by a timer under OS control. The process returns to its ready state in the wait line for CPU service, the ready queue.

• A high priority process arrives or is made to transition to the ready state, the OS interrupts the running process if it has a lower priority.

Page 71: Chapter 1 Basic Concepts of Operating Systems. 2 Software A program is a sequence of instructions that enables the computer to carry out some specific

71

CPU and I/O Devices

Basic queues in the CPU and I/O devices that a process joins while waiting for service in the computer system.