SlideShare a Scribd company logo
1 of 38
GANDHI INSTITUTE FOR EDUCATION & TECHNOLOGY
Baniatangi, Bhubaneswar
FOR 6TH SEM (CSE, ECE, EEE)
Prepared By:
Santosh Kumar Rath
Operating System
1
Introduction to Operating System:
An operating system is a program that acts as an intermediary between a
user of a computer and the computer hardware. The purpose of an operating
system is to provide an environment in which a user can execute program.
System Components
An operating system is an important part of almost every computer system.
A computer system can be divided roughly into four components:
(i) Hardware
(ii) Operating system
(iii) Applications programs
(iv) The users
1. Hardware
 The hardware- the central processing unit (CPU), the memory, and the
input /output (I/O) devices - provides the basic computing resources
for the system.
2. Operating System
 An operating system is a control program.
 A control program controls the execution of user programs to prevent
errors and improper use of the computer.
Operating System
2
 It provides a basis for the application program and acts as an
intermediary between the user and computer.
3. Application Program
 It help the user to perform the singular or multiple related tasks.
 It help the program to solve in real work.
 The applications programs- such as compilers, database systems,
games, and business programs- define the ways in which these
resources are used to solve the computing problems of the users.
Simple Batch Systems
To speed up processing, jobs with similar needs were batched together and
were run through the computer as a group. Thus, the programmers would
leave their programs with the operator. The operator would sort programs
into batches with similar requirements and, as the computer became
available, would run each batch. The output from each job would be sent
back to the appropriate programmer.
Demerits
 The lack of interaction between the user and the job while that job is
executing.
 In this execution environment, the CPU is often idle.
SPOOLING
The expansion of spooling is the simultaneous peripheral operation
on-line .For example if two or more users issue the print command, and the
Operating System
3
printer can accept the requests .Even the printer printing some other jobs.
The printer printing one job at the same time the “spool disk” can load some
other jobs.
„Spool disk‟ is a temporary buffer, it can read data from the secondary
storage devices directly. Simultaneously the CPU executing some other job in
the spool disk , at the same time the printer printing the third job. So three
jobs are running simultaneously.
Multi-programming Systems:
It is a technique to execute the number of the program
simultaneously by a single processor. In this case the number of the
processes are reside in main memory at a time. The operating system picks
and begins to execute one of the job in the main memory.
In non-multiprogramming system , the CPU can execute only one
program at a time , if the running program waiting for any I/O device , the
CPU become idle, so it will effect on the performance of the CPU. But in the
multiprogramming the CPU switches from that job to another job in the job
pool. So the CPU is not idle at any time.
This idea is common in other life situations. A lawyer does not have only one
client at a time. Rather, several clients may be in the process of being served
at the same time..) Multiprogramming is the first instance where the
operating system must make decisions for the users.
Advantages:-
Operating System
4
 Multiprogramming increases CPU utilization .
 CPU is never idle , so the performance of CPU will increase.
 Throughput of the CPU may also increase.
Time-Sharing Systems
Time sharing, or multitasking, is a logical extension of multiprogramming.
Multiple jobs are executed by the CPU switching between them, but the
switches occur so frequently that the users may interact with each program
while it is running.
Time-sharing systems were developed to provide interactive use of a
computer system at a reasonable cost. A time-shared operating system uses
CPU scheduling and multiprogramming to provide each user with a small
portion of a time-shared computer.
Time-sharing operating systems are CTTS , Multics , Cal ,Unix .
Distributed Systems
A distributed system is a collection of physically separate, possibly
heterogeneous computer systems that are networked to provide the users
with access to the various resources that the system maintains. The
processor can‟t share the memory or clock , each processor has its.
Advantages:
 Increases computation speed
 Increases functionality
 Increases the data availability, and reliability.
Operating System
5
Network Operating System :
A network operating system is an operating system that provides features
such as file sharing across the network and that includes a communication
scheme that allows different processes on different computers to exchange
messages. A computer running a network operating system acts
autonomously from all other computers on the network, although it is aware
of the network and is able to communicate with other networked computers.
Parallel System:
A system consisting of more than one processor and it is tightly coupled then it is
known as parallel system. In parallel systems number of the processor
executing their job parallel.
Tightly Coupled:-The system having more than one processor in close
communication ,sharing the computer bus , the clock , and some times
memory and peripheral devices. These are referred to as the “tightly
coupled” system.
Advantages:-
Increases throughput.
Increases reliability.
Special-Purpose Systems:
Operating System
6
The discussion thus far has focused on general-purpose computer systems
that we are all familiar with. There are, however, different classes of
computer systems whose functions are more limited and whose objective is
to deal with limited computation domains.
Real-Time Embedded Systems
A real-time operating system (RTOS) is an operating system (OS) intended to serve real-
time application requests. It must be able to process data as it comes in, typically without buffering
delays. A real-time system is used when rigid time requirements have been
placed on the operation of a processor or the flow of data; thus, it is often
used as a control device in a dedicated application. Sensors bring data to the
computer. The computer must analyze the data and possibly adjust controls
to modify the sensor inputs. Systems that control scientific experiments,
medical imaging systems, industrial control systems, and certain display
systems are realtime systems. Some automobile-engine fuel-injection
systems, home-appliance controllers, and weapon systems are also real-
time systems.
A real-time system has well-defined, fixed time constraints. Processing must
be done within the defined constraints, or the system will fail. For instance, it
would not do for a robot arm to be instructed to halt after it had smashed
into the car it was building. A real-time system functions correctly only if it
returns the correct result within its time constraints. Contrast this system
with a time-sharing system, where it is desirable (but not mandatory) to
respond
quickly, or a batch system, which may have no time constraints at all.
Operating System
7
SYSTEM STRUCTURES
Operating-System Services
OS provides an environment for execution of programs. It provides certain
services to programs and to the users of those programs. OS services
are provided for the convenience of the programmer, to make the
programming task easier.
One set of SOS services provides functions that are helpful to the user –
 User interface: All OS have a user interface(UI).Interfaces are of three
types- Command Line Interface: uses text commands and a method
for entering them Batch interface: commands and directives to
control those commands are entered into files and those files are
executed. Graphical user interface: This is a window system with
a pointing device to direct I/O, choose from menus and make
selections and a keyboard to enter text.
 Program execution: System must be able to load a program
into memory and run that program. The program must be able to
end its execution either normally or abnormally.
Operating System
8
 I/O operations: A running program may require I/O which may
involve a file or an I/O device. For efficiency and protection, users
cannot control I/O devices directly.
 File system manipulation: Programs need to read and write files
and directories. They also need to create and delete them by
name, search for a given file, and list file information.
 Communications: One process might need to exchange information
with another process.Such communication may occur between
processes that are executing on the same computer or between
processes that are executing on different computer systems tied
together by a computer network. Communications may be
implemented via shared memory or through message passing.
 Error detection: OS needs to be constantly aware of possible errors.
Errors may occur in the CPU and memory hardware, in I/O devices and
in the user program. For each type of error, OS takes appropriate
action to ensure correct and consistent computing.
Another set of OS functions exist for ensuring efficient operation of the
system. They are-
a. Resource allocation: When there are multiple users or multiple jobs
running at the same time, resources must be allocated to each of them.
Different types of resources such as CPU cycles, main memory and file
storage are managed by the operating system.
Operating System
9
b. Accounting: Keeping track of which users use how much and what
kinds of computer resources.
c. Protection and security: Controlling the use of information stored in
a multiuser or
networked computer system. Protection involves ensuring that all
access to system
resources is controlled. Security starts with requiring each user to
authenticate himself or
herself to the system by means of password and to gain access to system
resources.
System Calls
System calls provide an interface to the services made available by an
operating system.
Operating System
10
An example to illustrate how system calls are used:
Writing a simple program to read data from one file and copy them to
another file-
a) First input required is names of two files – input file and output
file. Names can be specified in many ways- One approach is for the
program to ask the user for the names of two files. In an interactive
system, this approach will require a sequence of system calls, to write
a prompting message on screen and then read from the keyboard the
characters that define the two files. On mouse based and icon based
systems, a menu of file names is displayed in a window where the user
can use the mouse to select the source names and a window can be
opened for the destination name to be specified.
b) Once the two file names are obtained, program must open the
input file and create the output file. Each of these operations requires
another system call. Possible error conditions –When the program tries to
open input file, no file of that name may exist or file is protected
against access. Program prints a message on console and terminates
abnormally. If input file exists, we must create a new output file. If the
output file with the same name exists, the situation caused the program to
abort or delete the existing file and create a new one. Another option is to
ask the user(via a sequence of system calls) whether to replace the existing
file or to abort the program.
Operating System
11
When both files are set up, a loop reads from the input file and writes to the
output file (system calls respectively). Each read and write must return status
information regarding various possible error conditions. After entire file
is copied, program closes both files, write a message to the console or
window and finally terminate normally.
Application developers design programs according to application
programming interface (API). API specifies set of functions that are available
to an application programmer.
The functions that make up the API typically invoke the actual system
calls on behalf of the application programmer. Benefits of programming
rather than invoking actual system calls:
 Program portability – An application programmer designing a program
using an API can expect program to compile and run on any system
that supports the same API.
 Actual system calls can be more detailed and difficult to work
with than the API available to an application programmer.
The run time support system ( a set of functions built into libraries included
with a compiler) for most programming languages provides a system call
Operating System
12
interface that serves as a link to system calls made available by OS.
The system call interface intercepts function calls in the API and
invokes the necessary system call within the operating system. A number is
associated with each system call and the system call interface maintains
a table indexed according to these numbers. System call interface then
invokes the intended system call in the OS kernel and returns the
status of the system call and return any values.
System calls occur in different ways, depending on the computer in
use – more information is required than simply the identity of the
desired system call. The exact type and amount of information vary
according to the particular OS and call.
Three general methods are used to pass parameters to OS-
I. Pass the parameters in registers
II. Storing parameters in blocks or tables in memory and the address of the
block id passed as a parameter in a register
III. Placing or pushing parameters onto the stack by the program and
popping off the stack by the OS.
Types of system calls
Five major categories:
1) Process control
end, abort
load, execute
Operating System
13
create process, terminate process
get process attributes, set process attributes
wait for time
wait event, signal event
allocate and free memory
2) File Management
create file, delete file
open, close
read, write, reposition
get file attributes, set file attributes
3) Device management
request device, release device
read, write, reposition
get device attributes, set device attributes
logically attach or detach devices
4) Information maintenance
get time or date, set time or date
get system data, set system data
get process, file or device attributes
set process, file or device attributes
5) Communications
create, delete communication connection
send, receive messages
Operating System
14
transfer status information
attach or detach remote devices
System Programs
Operating System
15
System programs provide a convenient environment for program
development and execution. They can be divided into these categories-
File management: These programs create, delete, copy, rename, print,
dump, list and manipulate files and directories.
Status information: Some programs ask the system for the date, time,
and amount of available memory or disk space, number of users.
File modification: Text editors may be available to create and modify the
content of files stored on disk or other storage devices.
Programming language support: Compilers, assemblers, debuggers and
interpreters for common programming languages are often provided to the
user with the OS.
Program loading and execution: Once a program is assembled or
compiled, it must be loaded into memory to be executed. System
provides absolute loaders, relocatable loaders, linkage editors and overlay
loaders.
Communications: These programs provide the mechanism for creating
virtual connections among processes, users and computer systems.
In addition to systems programs, OS are supplied with programs that
are useful in solving common problems or performing operations. Such
programs include web browsers, word processors and text formatters,
spread sheets, database systems etc. These programs are known as
system utilities or application programs.
Operating System
16
PROCESS MANAGEMENT
Current day computer systems allow multiple programs to be loaded into
memory and executed concurrently. Process is nothing but a program in
execution. A process is the unit of work in a modern time sharing
system. A system is a collection of processes: operating system
processes executing operating system code and user processes
executing user code. By switching CPU between processes, the operating
system can make the computer more productive.
Overview
A batch system executes jobs whereas a time shared system has user
programs or tasks. On a single user system, user may be able to run
several programs at one time: a word processor, a web browser and an
e-mail package. All of these are called processes.
The Process
A process is a program in execution. A process is more than a program code
sometimes known as text section. It also includes the current activity as
represented by the value of the program counter and the contents of the
processor‟s registers. A process generally also includes the process stack
which contains temporary data and a data section which contains global
variables.
A process may also include a heap which is memory that is
dynamically allocated during process run time. Program itself is not a
Operating System
17
process, a program is a passive entity such as a file containing a list
of instructions stored on disk (called an executable file) whereas
process is an active entity with a program counter specifying the next
instruction to execute and a set of associated resources. A program
becomes a process when an executable file is loaded into memory.
Although two processes may be associated with the same program, they are
considered two separate execution sequences.
Process State
As a process executes, it changes state. The state of a process is
defined in part by the current activity of that process. Each process may
be in one of the following states-
New: The process is being created.
Running: Instructions are being executed.
Waiting: The process is waiting for some event to occur.
Operating System
18
Ready: The process is waiting to be assigned to the processor.
Terminated: The process has finished execution.
Process Control Block
Each process is represented in the operating system by a process
control block (PCB) also called task control block. It contains many
pieces of information associated with a specific process including:
Process State: The state may be new, ready, running, waiting, halted etc.
Process Number: Unique number which is assigned to a program at time of
its execution.
Program Counter: The counter indicates the address of the next instruction
to be executed for this process.
CPU registers: The registers vary in number and type depending on the
computer architecture.
Operating System
19
CPU scheduling information: This information includes a process priority,
pointers to scheduling queues, and other scheduling parameters.
Memory management information: This information may include such
information as the value of base and limit registers etc.
Accounting information: This information includes the amount of CPU and
real time used, time limits etc.
I/O status information: This information includes the list of I/O devices
allocated to the process, etc.
Threads
Process is a program that performs a single thread of execution. A
single thread of control allows the process to perform only one task at one
time.
Process Scheduling
Operating System
20
The objective of multi programming is to have some process running
at all times to maximize CPU utilization. The objective of time sharing
is to switch the CPU among processes so frequently that users can
interact with each program while it is running. To meet these
objectives, the process scheduler selects an available process for
program execution on the CPU. For a single processer system, there will
never be more than one running process.
Scheduling Queues
Job queue: As processes enter the system, they are put inside the job queue,
which consists of all processes in the system.
Ready queue: The processes that are residing in main memory and are
ready and waiting to execute are kept on a list called the ready queue.
This queue is stored as a linked list. A ready queue header contains pointers
Operating System
21
to the first and final PCB‟s in the list. Each PCB includes a pointer field that
points to the next PCB in the ready queue.
Device queue: When a process is allocated the CPU, it executes for a while
and eventually quits, is interrupted or waits for the occurrence of a particular
event such as the completion of an I/O request. The list of processes waiting
for a particular I/O device is called a device queue. Each device has its own
device queue.
Queuing diagram
A common representation for process scheduling is queuing diagram. Each
rectangular box represents a queue. Two types of queues are present:
ready queue and a set of device queues. Circles represent the
resources that serve the queues and the arrows indicate the flow of
processes in the system.
Operating System
22
A new process is initially put in the ready queue. It waits there until it is
selected for execution or is dispatched. Once the process is allocated the
CPU and is executing, one of the following events might occur –
a) The process could issue and I/O request and then be placed in the I/O
queue.
b) The process could create a new sub process and wait for the sub
process‟s termination.
c) The process could be removed forcibly from the CPU as a result of
an interrupt and be put back in the ready queue.
Schedulers
A process migrated among the various scheduling queues throughout its life
time. The OS must select for scheduling purposes, processes from these
queues and this selection is carried out by scheduler.
In a batch system, more processes are submitted than can be
executed immediately. These processes are spooled to a mass storage
device (disk) where they are kept for later execution. The long term
scheduler or job scheduler selects processes from this pool and loads
them into memory for execution. The short term scheduler or CPU
scheduler selects from among the processes that are ready to execute and
allocates the CPU to one of them. The distinction between these two lies
in the frequency of execution. The long term scheduler controls the
degree of multi programming (the number of processes in memory). Most
Operating System
23
processes can be described as either I/O bound or CPU bound. An I/O bound
process is one that spends more of its time doing I/O than it spends doing
computations. A CPU bound process generates I/O requests infrequently
using more of its time doing computations. Long term scheduler must
select a good mix of I/O bound and CPU bound processes. A system
with best performance will have a combination of CPU bound and I/O bound
processes.
Some operating systems such as time sharing systems may introduce
additional/intermediate level of scheduling. Idea behind medium term
scheduler is that sometimes it can be advantageous to remove
processes from memory and thus reduce the degree of
multiprogramming. Later the process can be reintroduced into memory
and its execution can be continued where it left off. This scheme is
called swapping. The process is swapped out and is later swapped in by the
medium term scheduler.
Context switch
Interrupts cause the OS to change a CPU from its current task and to run a
kernel routine. When an interrupt occurs, the system needs to save the
Operating System
24
current context of the process currently running on the CPU so that it can
restore that context when its processing is done, essentially suspending the
process and then resuming it. The context is represented in the PCB of
the process, it includes the value of CPU registers, process state and
memory management information. We perform a state save of the current
state of the CPU and then state restore to resume operations.
Switching the CPU to another process requires performing a state save of the
current process and a state restore of a different process. This task is
known as context switch. Kernel saves the context of the old process in its
PCB and loads the saved context of the new process scheduled to run.
Context switch time is pure overhead. Its speed varies from machine to
machine depending on the memory speed, the number of registers that
must be copied and the existence of special instructions. Context switch
times are highly dependent on hardware support.
Multithreading
Thread is a basic unit of CPU utilization. Support for threads may be
provided either at the user level for user threads or by the kernel for
kernel threads. User threads are supported above the kernel and are
managed without kernel support whereas kernel threads are supported
and managed directly by the operating system.
Benefits of multi threaded programming are:
Responsiveness: Multi threading an interactive application may allow a
program to continue running even if part of it is blocked or is
Operating System
25
performing a lengthy operation, thereby increasing responsiveness to the
user.
Resource interaction: Threads share the memory and the resources of the
process to which they belong. The benefit of sharing code and data is
that it allows an application to have several different threads of activity
within the same address space.
Economy: Allocating memory and resources for process creation is costly.
Because threads share resources of the process to which they belong, it is
more economical to create and context switch threads.
Utilization of multi processor architecture: The benefits of multi
threading can be greatly increased in a multi processor architecture where
threads may be running in parallel on different processors. Multi threading
on a multi CPU machine increases concurrency.
User threads are supported above the kernel and are managed without
kernel support whereas kernel threads are supported and managed directly
by the operating system.
CPU scheduling is the basis of multi programmed operating systems. By
switching CPU among processes, the OS can make the computer more
productive. On operating systems that support threads, it is kernel level
threads and not processes that are scheduled by operating system. But
process scheduling and thread scheduling are often used interchangeably.
Operating System
26
In a single processor system, only one process can run at a time; others
must wait until CPU is free and can be rescheduled. The objective of multi
programming is to have some process running at all times to
maximize CPU utilization. Under multi programming, several processes are
kept in memory at one time. When one process has to wait, the OS takes the
CPU away from that process and gives the CPU to another process. As CPU is
one of the primary computer resources, its scheduling is central to operating
system design.
Three common ways of establishing a relationship between user level
and kernel level threads are:
Many to one model - Maps many user level threads to one kernel thread.
Thread management is done by the thread library in user space hence
it is efficient but entire process will block if a thread makes a blocking
system call. As only one thread can access the kernel at a time, multiple
threads are unable to run in parallel on multi processors.
Operating System
27
One to one model - Maps each user thread to kernel thread. It
allows more concurrency by allowing another thread to run when a
thread makes a blocking system call; it also allows multiple threads to
run in parallel on multi processors. Disadvantage is that creating a user
thread requires creating the corresponding kernel thread.
Many to many model - Multiplexes many user level threads to a
smaller or equal number of kernel level threads. The number of kernel
threads may be specific to either a particular application or a particular
machine. Developers can create as many user threads as necessary and the
corresponding kernel threads can run in parallel on a multi processor.
Also, when a thread performs a blocking system call, the kernel can
schedule another thread for execution.
Operating System
28
On operating systems that support threads, it is kernel level threads that are
being scheduled by operating system. User level threads are managed by
thread library. To run on a CPU, user level threads must be mapped to an
associated kernel level thread although this mapping may be indirect
and may use a light weight process.
PROCESS SCHEDULING:
Process is an executing program with a single thread of control. Most
operating systems provide features enabling a process to contain multiple
threads of control. A thread is a basic unit of CPU utilization; it comprises
of a thread ID, a program counter, a register set and a stack. It
shares with other threads belonging to the same process its code
section, data section and other operating system resources such as open
files and signals. A traditional or heavy weight process has a single thread of
control.
CPU – I/O burst cycle:
Process execution consists of a cycle of CPU execution and I/O wait.
Processes alternate between these two states. Process execution begins with
CPU burst followed by an I/O burst and so on. The final CPU burst ends with
a system request to terminate execution.
Operating System
29
An I/O bound program has many short CPU bursts. A CPU bound
program might have a few long CPU bursts.
CPU scheduler:
Whenever the CPU becomes idle, the operating system must select one
of the processes in the ready queue to be executed. The selection
process is carried out by the short term scheduler or CPU scheduler.
The scheduler selects a process from the processes in memory that are ready
to execute and allocates the CPU to that process.
The ready queue is not necessarily a first in first out queue. A ready queue
can be implemented as a FIFO queue, a priority queue, a tree or an
Operating System
30
unordered linked list. All the processes in the ready queue are lined
up waiting for a chance to run on the CPU. The records in the queue are
process control blocks of the processes.
Pre-emptive scheduling:
CPU scheduling decisions may take place under the following four
conditions-
a) When a process switches from the running state to the waiting state
b) When a process switches from the running state to the ready state
c) When a process switches from the waiting state to the ready state
d) When a process terminates
When scheduling takes place under conditions 1 and 4, scheduling scheme is
non - pre emptive or co-operative. Else it is called pre emptive.
Under non pre emptive scheduling, once the CPU has been allocated
to a process, the process keeps the CPU until it releases the CPU
either by terminating or by switching to the waiting state. Pre emptive
scheduling incurs cost associated with access to shared data. Pre emption
also affects the design of the operating system kernel.
Dispatcher:
The dispatcher is the module that gives control of the CPU to the
process selected by the short term scheduler. This function involves-
a) Switching context
Operating System
31
b) Switching to user mode
c) Jumping to the proper location in the user program to restart that
program
Dispatcher should be as fast as possible since it is invoked during every
process switch. The time it takes for the dispatcher to stop one process
and start another running is called dispatch latency.
Scheduling criteria:
Different CPU scheduling algorithms have different properties. Criteria for
comparing CPU scheduling algorithms-
a) CPU utilization: Keep the CPU as busy as possible
b) Through put: One measure of work of CPU is the number of processes
that are completed per time unit called through put.
c) Turnaround time: The interval from the time of submission of a
process to the time of completion is the turnaround time. Turnaround
time is the sum of the periods spent waiting to get into memory, waiting
in the ready queue, executing on the CPU and doing I/O.
d) Waiting time: It is the sum of the periods spent waiting in the ready
queue.
e) Response time: The time it takes for the process to start responding but
is not the time it takes to output the response.
Operating System
32
It is desirable to maximize CPU utilization and through put and to
minimize turnaround time, waiting time and response time.
Scheduling algorithms:
First Come First Serve:
This is the simplest CPU scheduling algorithm. The process that
requests the CPU first is allocated the CPU first. The implementation of
FCFS is managed with a FIFO queue. When a process enters the ready
queue, its PCB is linked onto the tail of the queue. When the CPU is
free, it is allocated to the process at the head of the queue. The running
process is then removed from the queue.
The average waiting time under FCFS is often quite long. The FCFS
scheduling algorithm is non pre-emptive.
Once the CPU has been allocated to a process, that process keeps
the CPU until it releases the CPU either by terminating or by
requesting I/O. It is simple, fair, but poor performance. Average
queuing time may be long.
Operating System
33
Shortest Job First:
This algorithm associates with each process the length of the process‟s next
CPU burst. When the CPU is available, it is assigned to the process that has
the smallest next CPU burst. If the next CPU bursts of two processes are the
same, FCFS scheduling is used to break the tie.
Priority:
Operating System
34
The SJF is a special case of the general priority scheduling algorithm.
A priority is associated with each process and CPU is allocated to the
process with highest priority. Equal priority processes are scheduled in
FCFS order. An SJF algorithm is simply a priority algorithm where the
priority is the inverse of the predicted next CPU burst. The larger the
CPU burst, the lower the priority. Priorities are generally indicated by some
fixed range of numbers usually 0 to 7.
Priorities can be defined either internally or externally. Internally
defined priorities use some measurable quantity to computer the
priority of a process. External priorities are set by criteria outside the
operating system.
Priority scheduling can be either pre emptive or non pre emptive. When a
process arrives at the ready queue, its priority is compared with the
priority of the currently running process. A preemptive priority
scheduling algorithm will preempt the CPU is the priority of the newly
arrived process is higher than the priority of the currently running
process. A non preemptive priority scheduling algorithm will put the new
process at the head of the ready queue.
The major problem with priority scheduling algorithm is indefinite
blocking or starvation. A process that is ready to run but waiting for
the CPU can be considered blocked. A priority scheduling algorithm
can leave some low priority processes waiting indefinitely. A solution
to the problem of indefinite blockage of low priority processes is
Operating System
35
aging. Aging is a technique of gradually increasing the priority of
processes that wait in the system for a long time.
Round Robin:
The round robin scheduling algorithm is designed for time sharing systems.
It is similar to FCFS scheduling but preemption is added to switch
between processes. A small unit of time called a time quantum or time
slice is defined. A time quantum is generally from 10 to 100 milli seconds.
The ready queue is treated as a circular queue. The CPU scheduler goes
around the ready queue allocating the CPU to each process for a time
interval of up to 1 time quantum. To implement RR scheduling, ready
queue is implemented as a FIFO queue. New processes are added to
the tail of ready queue. The CPU scheduler picks the first process
from the ready queue, sets the timer to interrupt after 1 time quantum
and dispatches the process.
The process may either have a CPU burst of less than 1 time
quantum. Then, the process itself will release the CPU voluntarily. The
scheduler will then proceed to the next process in the ready queue. Else if
the CPU burst of the currently running process is longer than 1 time
quantum, the timer will go off and will cause an interrupt to the
operating system. A context switch will be executed and the process will
be put at the tail of the ready queue. The CPU scheduler will then select the
next process in the ready queue.
Operating System
36
In the RR scheduling algorithm, no process is allocated the CPU for more
than 1 time quantum in a row. If a process‟s CPU burst exceeds 1 time
quantum, that process is preempted and is put back in the ready queue.
Thus this algorithm is preemptive. The performance of the RR algorithm
depends heavily on the size of time quantum. If the time quantum is
extremely large, the RR policy is same as the FCFS policy. If the time
quantum is extremely small, the RR approach is called processor sharing.
Algorithm evaluation
Selection of an algorithm is difficult. The first problem is defining the
criteria to be used in selecting an algorithm. Criteria are often defined
in terms of CPU utilization, response time or through put. Criteria
includes several measures such as-
Operating System
37
a) Maximizing CPU utilization under the constraint that the maximum
response time is 1 second.
b) Maximizing through put such that turnaround time is linearly
proportional to total execution time.

More Related Content

What's hot

Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory managementrprajat007
 
Presentation on Operating System & its Components
Presentation on Operating System & its ComponentsPresentation on Operating System & its Components
Presentation on Operating System & its ComponentsMahmuda Rahman
 
Computer system architecture
Computer system architectureComputer system architecture
Computer system architectureKumar
 
Multiprogramming&timesharing
Multiprogramming&timesharingMultiprogramming&timesharing
Multiprogramming&timesharingTanuj Tyagi
 
Operating system concepts
Operating system conceptsOperating system concepts
Operating system conceptsArnav Chowdhury
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"Ra'Fat Al-Msie'deen
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OSvampugani
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Mukesh Chinta
 
Operating system services 9
Operating system services 9Operating system services 9
Operating system services 9myrajendra
 
Chapter 11 - File System Implementation
Chapter 11 - File System ImplementationChapter 11 - File System Implementation
Chapter 11 - File System ImplementationWayne Jones Jnr
 

What's hot (20)

Operating system memory management
Operating system memory managementOperating system memory management
Operating system memory management
 
Memory management
Memory managementMemory management
Memory management
 
Os ppt
Os pptOs ppt
Os ppt
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating Systems
 
Process state in OS
Process state in OSProcess state in OS
Process state in OS
 
Presentation on Operating System & its Components
Presentation on Operating System & its ComponentsPresentation on Operating System & its Components
Presentation on Operating System & its Components
 
Fragmentaton
Fragmentaton Fragmentaton
Fragmentaton
 
Computer system architecture
Computer system architectureComputer system architecture
Computer system architecture
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 
Multiprogramming&timesharing
Multiprogramming&timesharingMultiprogramming&timesharing
Multiprogramming&timesharing
 
Operating system concepts
Operating system conceptsOperating system concepts
Operating system concepts
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"
 
operating system lecture notes
operating system lecture notesoperating system lecture notes
operating system lecture notes
 
BANKER'S ALGORITHM
BANKER'S ALGORITHMBANKER'S ALGORITHM
BANKER'S ALGORITHM
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 
Underlying principles of parallel and distributed computing
Underlying principles of parallel and distributed computingUnderlying principles of parallel and distributed computing
Underlying principles of parallel and distributed computing
 
Operating system services 9
Operating system services 9Operating system services 9
Operating system services 9
 
Chapter 11 - File System Implementation
Chapter 11 - File System ImplementationChapter 11 - File System Implementation
Chapter 11 - File System Implementation
 

Viewers also liked

Unit 4 Multimedia CSE Vth sem
Unit 4 Multimedia CSE Vth semUnit 4 Multimedia CSE Vth sem
Unit 4 Multimedia CSE Vth semNANDINI SHARMA
 
3D transformation - Unit 3 Computer grpahics
3D transformation - Unit 3 Computer grpahics3D transformation - Unit 3 Computer grpahics
3D transformation - Unit 3 Computer grpahicsNANDINI SHARMA
 
Bce notes unit 1 be 205
Bce notes unit 1 be 205Bce notes unit 1 be 205
Bce notes unit 1 be 205NANDINI SHARMA
 
Unit 5 animation notes
Unit 5 animation notesUnit 5 animation notes
Unit 5 animation notesNANDINI SHARMA
 
Database Management System
Database Management SystemDatabase Management System
Database Management SystemNANDINI SHARMA
 
Operating system concepts (notes)
Operating system concepts (notes)Operating system concepts (notes)
Operating system concepts (notes)Sohaib Danish
 
Computer Network notes (handwritten) UNIT 1
Computer Network notes (handwritten) UNIT 1Computer Network notes (handwritten) UNIT 1
Computer Network notes (handwritten) UNIT 1NANDINI SHARMA
 
Notes 2D-Transformation Unit 2 Computer graphics
Notes 2D-Transformation Unit 2 Computer graphicsNotes 2D-Transformation Unit 2 Computer graphics
Notes 2D-Transformation Unit 2 Computer graphicsNANDINI SHARMA
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphicsSHIVANI SONI
 

Viewers also liked (12)

Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
Dbms Lecture Notes
Dbms Lecture NotesDbms Lecture Notes
Dbms Lecture Notes
 
Unit 4 Multimedia CSE Vth sem
Unit 4 Multimedia CSE Vth semUnit 4 Multimedia CSE Vth sem
Unit 4 Multimedia CSE Vth sem
 
3D transformation - Unit 3 Computer grpahics
3D transformation - Unit 3 Computer grpahics3D transformation - Unit 3 Computer grpahics
3D transformation - Unit 3 Computer grpahics
 
Bce notes unit 1 be 205
Bce notes unit 1 be 205Bce notes unit 1 be 205
Bce notes unit 1 be 205
 
Unit 5 animation notes
Unit 5 animation notesUnit 5 animation notes
Unit 5 animation notes
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 
Imp notes dbms
Imp notes dbmsImp notes dbms
Imp notes dbms
 
Operating system concepts (notes)
Operating system concepts (notes)Operating system concepts (notes)
Operating system concepts (notes)
 
Computer Network notes (handwritten) UNIT 1
Computer Network notes (handwritten) UNIT 1Computer Network notes (handwritten) UNIT 1
Computer Network notes (handwritten) UNIT 1
 
Notes 2D-Transformation Unit 2 Computer graphics
Notes 2D-Transformation Unit 2 Computer graphicsNotes 2D-Transformation Unit 2 Computer graphics
Notes 2D-Transformation Unit 2 Computer graphics
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphics
 

Similar to Operating system notes

Fundamental Operating System Concepts.pptx
Fundamental Operating System Concepts.pptxFundamental Operating System Concepts.pptx
Fundamental Operating System Concepts.pptxUttara University
 
LM1 - Computer System Overview, system calls
LM1 - Computer System Overview, system callsLM1 - Computer System Overview, system calls
LM1 - Computer System Overview, system callsmanideepakc
 
Session1 intro to_os
Session1 intro to_osSession1 intro to_os
Session1 intro to_osKalyani Patil
 
Ch1kiit [compatibility mode]
Ch1kiit [compatibility mode]Ch1kiit [compatibility mode]
Ch1kiit [compatibility mode]Amit Gupta
 
Advanced computer architecture lesson 1 and 2
Advanced computer architecture lesson 1 and 2Advanced computer architecture lesson 1 and 2
Advanced computer architecture lesson 1 and 2Ismail Mukiibi
 
Operating system || Chapter 1: Introduction
Operating system || Chapter 1: IntroductionOperating system || Chapter 1: Introduction
Operating system || Chapter 1: IntroductionAnkonGopalBanik
 
chapter 1 intoduction to operating system
chapter 1 intoduction to operating systemchapter 1 intoduction to operating system
chapter 1 intoduction to operating systemSiddhi Viradiya
 
MYSQL DATABASE Operating System Part2 (1).pptx
MYSQL DATABASE Operating System Part2 (1).pptxMYSQL DATABASE Operating System Part2 (1).pptx
MYSQL DATABASE Operating System Part2 (1).pptxArjayBalberan1
 
Types of Operating System-converted.pdf
Types of Operating System-converted.pdfTypes of Operating System-converted.pdf
Types of Operating System-converted.pdfOmid695066
 
Operating System Lecture Notes
Operating System Lecture NotesOperating System Lecture Notes
Operating System Lecture NotesFellowBuddy.com
 
Operting system
Operting systemOperting system
Operting systemKAnurag2
 
Operating system Concepts
Operating system Concepts Operating system Concepts
Operating system Concepts RANVIJAY GAUR
 
Operating system 2
Operating system 2Operating system 2
Operating system 2matsapit
 
Operating Systems
Operating SystemsOperating Systems
Operating Systemsachal02
 

Similar to Operating system notes (20)

Os notes
Os notesOs notes
Os notes
 
Fundamental Operating System Concepts.pptx
Fundamental Operating System Concepts.pptxFundamental Operating System Concepts.pptx
Fundamental Operating System Concepts.pptx
 
LM1 - Computer System Overview, system calls
LM1 - Computer System Overview, system callsLM1 - Computer System Overview, system calls
LM1 - Computer System Overview, system calls
 
Session1 intro to_os
Session1 intro to_osSession1 intro to_os
Session1 intro to_os
 
Ch1kiit [compatibility mode]
Ch1kiit [compatibility mode]Ch1kiit [compatibility mode]
Ch1kiit [compatibility mode]
 
Advanced computer architecture lesson 1 and 2
Advanced computer architecture lesson 1 and 2Advanced computer architecture lesson 1 and 2
Advanced computer architecture lesson 1 and 2
 
Operating system || Chapter 1: Introduction
Operating system || Chapter 1: IntroductionOperating system || Chapter 1: Introduction
Operating system || Chapter 1: Introduction
 
chapter 1 intoduction to operating system
chapter 1 intoduction to operating systemchapter 1 intoduction to operating system
chapter 1 intoduction to operating system
 
Operating System
Operating SystemOperating System
Operating System
 
MYSQL DATABASE Operating System Part2 (1).pptx
MYSQL DATABASE Operating System Part2 (1).pptxMYSQL DATABASE Operating System Part2 (1).pptx
MYSQL DATABASE Operating System Part2 (1).pptx
 
Os unit 1
Os unit 1Os unit 1
Os unit 1
 
Types of Operating System-converted.pdf
Types of Operating System-converted.pdfTypes of Operating System-converted.pdf
Types of Operating System-converted.pdf
 
Introduction to OS 1.ppt
Introduction to OS 1.pptIntroduction to OS 1.ppt
Introduction to OS 1.ppt
 
Operating System Lecture Notes
Operating System Lecture NotesOperating System Lecture Notes
Operating System Lecture Notes
 
Operting system
Operting systemOperting system
Operting system
 
Operating system Concepts
Operating system Concepts Operating system Concepts
Operating system Concepts
 
Operating System.pptx
Operating System.pptxOperating System.pptx
Operating System.pptx
 
Operating system 2
Operating system 2Operating system 2
Operating system 2
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
Operating systems1[1]
Operating systems1[1]Operating systems1[1]
Operating systems1[1]
 

More from SANTOSH RATH

Lesson plan proforma database management system
Lesson plan proforma database management systemLesson plan proforma database management system
Lesson plan proforma database management systemSANTOSH RATH
 
Lesson plan proforma progrmming in c
Lesson plan proforma progrmming in cLesson plan proforma progrmming in c
Lesson plan proforma progrmming in cSANTOSH RATH
 
Expected questions tc
Expected questions tcExpected questions tc
Expected questions tcSANTOSH RATH
 
Expected questions tc
Expected questions tcExpected questions tc
Expected questions tcSANTOSH RATH
 
Module wise format oops questions
Module wise format oops questionsModule wise format oops questions
Module wise format oops questionsSANTOSH RATH
 
( Becs 2208 ) database management system
( Becs 2208 ) database management system( Becs 2208 ) database management system
( Becs 2208 ) database management systemSANTOSH RATH
 
Expected Questions TC
Expected Questions TCExpected Questions TC
Expected Questions TCSANTOSH RATH
 
Expected questions tc
Expected questions tcExpected questions tc
Expected questions tcSANTOSH RATH
 
Expected questions for dbms
Expected questions for dbmsExpected questions for dbms
Expected questions for dbmsSANTOSH RATH
 
Expected questions for dbms
Expected questions for dbmsExpected questions for dbms
Expected questions for dbmsSANTOSH RATH
 
Oops model question
Oops model questionOops model question
Oops model questionSANTOSH RATH
 
System programming note
System programming noteSystem programming note
System programming noteSANTOSH RATH
 
Data structure using c bcse 3102 pcs 1002
Data structure using c bcse 3102 pcs 1002Data structure using c bcse 3102 pcs 1002
Data structure using c bcse 3102 pcs 1002SANTOSH RATH
 

More from SANTOSH RATH (20)

Lesson plan proforma database management system
Lesson plan proforma database management systemLesson plan proforma database management system
Lesson plan proforma database management system
 
Lesson plan proforma progrmming in c
Lesson plan proforma progrmming in cLesson plan proforma progrmming in c
Lesson plan proforma progrmming in c
 
Expected questions tc
Expected questions tcExpected questions tc
Expected questions tc
 
Expected questions tc
Expected questions tcExpected questions tc
Expected questions tc
 
Module wise format oops questions
Module wise format oops questionsModule wise format oops questions
Module wise format oops questions
 
2011dbms
2011dbms2011dbms
2011dbms
 
2006dbms
2006dbms2006dbms
2006dbms
 
( Becs 2208 ) database management system
( Becs 2208 ) database management system( Becs 2208 ) database management system
( Becs 2208 ) database management system
 
Rdbms2010
Rdbms2010Rdbms2010
Rdbms2010
 
Expected Questions TC
Expected Questions TCExpected Questions TC
Expected Questions TC
 
Expected questions tc
Expected questions tcExpected questions tc
Expected questions tc
 
Expected questions for dbms
Expected questions for dbmsExpected questions for dbms
Expected questions for dbms
 
Expected questions for dbms
Expected questions for dbmsExpected questions for dbms
Expected questions for dbms
 
Oops model question
Oops model questionOops model question
Oops model question
 
System programming note
System programming noteSystem programming note
System programming note
 
OS ASSIGNMENT 2
OS ASSIGNMENT 2OS ASSIGNMENT 2
OS ASSIGNMENT 2
 
OS ASSIGNMENT-1
OS ASSIGNMENT-1OS ASSIGNMENT-1
OS ASSIGNMENT-1
 
OS ASSIGNMENT 3
OS ASSIGNMENT 3OS ASSIGNMENT 3
OS ASSIGNMENT 3
 
Ds using c 2009
Ds using c 2009Ds using c 2009
Ds using c 2009
 
Data structure using c bcse 3102 pcs 1002
Data structure using c bcse 3102 pcs 1002Data structure using c bcse 3102 pcs 1002
Data structure using c bcse 3102 pcs 1002
 

Recently uploaded

Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 

Recently uploaded (20)

Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 

Operating system notes

  • 1. GANDHI INSTITUTE FOR EDUCATION & TECHNOLOGY Baniatangi, Bhubaneswar FOR 6TH SEM (CSE, ECE, EEE) Prepared By: Santosh Kumar Rath
  • 2. Operating System 1 Introduction to Operating System: An operating system is a program that acts as an intermediary between a user of a computer and the computer hardware. The purpose of an operating system is to provide an environment in which a user can execute program. System Components An operating system is an important part of almost every computer system. A computer system can be divided roughly into four components: (i) Hardware (ii) Operating system (iii) Applications programs (iv) The users 1. Hardware  The hardware- the central processing unit (CPU), the memory, and the input /output (I/O) devices - provides the basic computing resources for the system. 2. Operating System  An operating system is a control program.  A control program controls the execution of user programs to prevent errors and improper use of the computer.
  • 3. Operating System 2  It provides a basis for the application program and acts as an intermediary between the user and computer. 3. Application Program  It help the user to perform the singular or multiple related tasks.  It help the program to solve in real work.  The applications programs- such as compilers, database systems, games, and business programs- define the ways in which these resources are used to solve the computing problems of the users. Simple Batch Systems To speed up processing, jobs with similar needs were batched together and were run through the computer as a group. Thus, the programmers would leave their programs with the operator. The operator would sort programs into batches with similar requirements and, as the computer became available, would run each batch. The output from each job would be sent back to the appropriate programmer. Demerits  The lack of interaction between the user and the job while that job is executing.  In this execution environment, the CPU is often idle. SPOOLING The expansion of spooling is the simultaneous peripheral operation on-line .For example if two or more users issue the print command, and the
  • 4. Operating System 3 printer can accept the requests .Even the printer printing some other jobs. The printer printing one job at the same time the “spool disk” can load some other jobs. „Spool disk‟ is a temporary buffer, it can read data from the secondary storage devices directly. Simultaneously the CPU executing some other job in the spool disk , at the same time the printer printing the third job. So three jobs are running simultaneously. Multi-programming Systems: It is a technique to execute the number of the program simultaneously by a single processor. In this case the number of the processes are reside in main memory at a time. The operating system picks and begins to execute one of the job in the main memory. In non-multiprogramming system , the CPU can execute only one program at a time , if the running program waiting for any I/O device , the CPU become idle, so it will effect on the performance of the CPU. But in the multiprogramming the CPU switches from that job to another job in the job pool. So the CPU is not idle at any time. This idea is common in other life situations. A lawyer does not have only one client at a time. Rather, several clients may be in the process of being served at the same time..) Multiprogramming is the first instance where the operating system must make decisions for the users. Advantages:-
  • 5. Operating System 4  Multiprogramming increases CPU utilization .  CPU is never idle , so the performance of CPU will increase.  Throughput of the CPU may also increase. Time-Sharing Systems Time sharing, or multitasking, is a logical extension of multiprogramming. Multiple jobs are executed by the CPU switching between them, but the switches occur so frequently that the users may interact with each program while it is running. Time-sharing systems were developed to provide interactive use of a computer system at a reasonable cost. A time-shared operating system uses CPU scheduling and multiprogramming to provide each user with a small portion of a time-shared computer. Time-sharing operating systems are CTTS , Multics , Cal ,Unix . Distributed Systems A distributed system is a collection of physically separate, possibly heterogeneous computer systems that are networked to provide the users with access to the various resources that the system maintains. The processor can‟t share the memory or clock , each processor has its. Advantages:  Increases computation speed  Increases functionality  Increases the data availability, and reliability.
  • 6. Operating System 5 Network Operating System : A network operating system is an operating system that provides features such as file sharing across the network and that includes a communication scheme that allows different processes on different computers to exchange messages. A computer running a network operating system acts autonomously from all other computers on the network, although it is aware of the network and is able to communicate with other networked computers. Parallel System: A system consisting of more than one processor and it is tightly coupled then it is known as parallel system. In parallel systems number of the processor executing their job parallel. Tightly Coupled:-The system having more than one processor in close communication ,sharing the computer bus , the clock , and some times memory and peripheral devices. These are referred to as the “tightly coupled” system. Advantages:- Increases throughput. Increases reliability. Special-Purpose Systems:
  • 7. Operating System 6 The discussion thus far has focused on general-purpose computer systems that we are all familiar with. There are, however, different classes of computer systems whose functions are more limited and whose objective is to deal with limited computation domains. Real-Time Embedded Systems A real-time operating system (RTOS) is an operating system (OS) intended to serve real- time application requests. It must be able to process data as it comes in, typically without buffering delays. A real-time system is used when rigid time requirements have been placed on the operation of a processor or the flow of data; thus, it is often used as a control device in a dedicated application. Sensors bring data to the computer. The computer must analyze the data and possibly adjust controls to modify the sensor inputs. Systems that control scientific experiments, medical imaging systems, industrial control systems, and certain display systems are realtime systems. Some automobile-engine fuel-injection systems, home-appliance controllers, and weapon systems are also real- time systems. A real-time system has well-defined, fixed time constraints. Processing must be done within the defined constraints, or the system will fail. For instance, it would not do for a robot arm to be instructed to halt after it had smashed into the car it was building. A real-time system functions correctly only if it returns the correct result within its time constraints. Contrast this system with a time-sharing system, where it is desirable (but not mandatory) to respond quickly, or a batch system, which may have no time constraints at all.
  • 8. Operating System 7 SYSTEM STRUCTURES Operating-System Services OS provides an environment for execution of programs. It provides certain services to programs and to the users of those programs. OS services are provided for the convenience of the programmer, to make the programming task easier. One set of SOS services provides functions that are helpful to the user –  User interface: All OS have a user interface(UI).Interfaces are of three types- Command Line Interface: uses text commands and a method for entering them Batch interface: commands and directives to control those commands are entered into files and those files are executed. Graphical user interface: This is a window system with a pointing device to direct I/O, choose from menus and make selections and a keyboard to enter text.  Program execution: System must be able to load a program into memory and run that program. The program must be able to end its execution either normally or abnormally.
  • 9. Operating System 8  I/O operations: A running program may require I/O which may involve a file or an I/O device. For efficiency and protection, users cannot control I/O devices directly.  File system manipulation: Programs need to read and write files and directories. They also need to create and delete them by name, search for a given file, and list file information.  Communications: One process might need to exchange information with another process.Such communication may occur between processes that are executing on the same computer or between processes that are executing on different computer systems tied together by a computer network. Communications may be implemented via shared memory or through message passing.  Error detection: OS needs to be constantly aware of possible errors. Errors may occur in the CPU and memory hardware, in I/O devices and in the user program. For each type of error, OS takes appropriate action to ensure correct and consistent computing. Another set of OS functions exist for ensuring efficient operation of the system. They are- a. Resource allocation: When there are multiple users or multiple jobs running at the same time, resources must be allocated to each of them. Different types of resources such as CPU cycles, main memory and file storage are managed by the operating system.
  • 10. Operating System 9 b. Accounting: Keeping track of which users use how much and what kinds of computer resources. c. Protection and security: Controlling the use of information stored in a multiuser or networked computer system. Protection involves ensuring that all access to system resources is controlled. Security starts with requiring each user to authenticate himself or herself to the system by means of password and to gain access to system resources. System Calls System calls provide an interface to the services made available by an operating system.
  • 11. Operating System 10 An example to illustrate how system calls are used: Writing a simple program to read data from one file and copy them to another file- a) First input required is names of two files – input file and output file. Names can be specified in many ways- One approach is for the program to ask the user for the names of two files. In an interactive system, this approach will require a sequence of system calls, to write a prompting message on screen and then read from the keyboard the characters that define the two files. On mouse based and icon based systems, a menu of file names is displayed in a window where the user can use the mouse to select the source names and a window can be opened for the destination name to be specified. b) Once the two file names are obtained, program must open the input file and create the output file. Each of these operations requires another system call. Possible error conditions –When the program tries to open input file, no file of that name may exist or file is protected against access. Program prints a message on console and terminates abnormally. If input file exists, we must create a new output file. If the output file with the same name exists, the situation caused the program to abort or delete the existing file and create a new one. Another option is to ask the user(via a sequence of system calls) whether to replace the existing file or to abort the program.
  • 12. Operating System 11 When both files are set up, a loop reads from the input file and writes to the output file (system calls respectively). Each read and write must return status information regarding various possible error conditions. After entire file is copied, program closes both files, write a message to the console or window and finally terminate normally. Application developers design programs according to application programming interface (API). API specifies set of functions that are available to an application programmer. The functions that make up the API typically invoke the actual system calls on behalf of the application programmer. Benefits of programming rather than invoking actual system calls:  Program portability – An application programmer designing a program using an API can expect program to compile and run on any system that supports the same API.  Actual system calls can be more detailed and difficult to work with than the API available to an application programmer. The run time support system ( a set of functions built into libraries included with a compiler) for most programming languages provides a system call
  • 13. Operating System 12 interface that serves as a link to system calls made available by OS. The system call interface intercepts function calls in the API and invokes the necessary system call within the operating system. A number is associated with each system call and the system call interface maintains a table indexed according to these numbers. System call interface then invokes the intended system call in the OS kernel and returns the status of the system call and return any values. System calls occur in different ways, depending on the computer in use – more information is required than simply the identity of the desired system call. The exact type and amount of information vary according to the particular OS and call. Three general methods are used to pass parameters to OS- I. Pass the parameters in registers II. Storing parameters in blocks or tables in memory and the address of the block id passed as a parameter in a register III. Placing or pushing parameters onto the stack by the program and popping off the stack by the OS. Types of system calls Five major categories: 1) Process control end, abort load, execute
  • 14. Operating System 13 create process, terminate process get process attributes, set process attributes wait for time wait event, signal event allocate and free memory 2) File Management create file, delete file open, close read, write, reposition get file attributes, set file attributes 3) Device management request device, release device read, write, reposition get device attributes, set device attributes logically attach or detach devices 4) Information maintenance get time or date, set time or date get system data, set system data get process, file or device attributes set process, file or device attributes 5) Communications create, delete communication connection send, receive messages
  • 15. Operating System 14 transfer status information attach or detach remote devices System Programs
  • 16. Operating System 15 System programs provide a convenient environment for program development and execution. They can be divided into these categories- File management: These programs create, delete, copy, rename, print, dump, list and manipulate files and directories. Status information: Some programs ask the system for the date, time, and amount of available memory or disk space, number of users. File modification: Text editors may be available to create and modify the content of files stored on disk or other storage devices. Programming language support: Compilers, assemblers, debuggers and interpreters for common programming languages are often provided to the user with the OS. Program loading and execution: Once a program is assembled or compiled, it must be loaded into memory to be executed. System provides absolute loaders, relocatable loaders, linkage editors and overlay loaders. Communications: These programs provide the mechanism for creating virtual connections among processes, users and computer systems. In addition to systems programs, OS are supplied with programs that are useful in solving common problems or performing operations. Such programs include web browsers, word processors and text formatters, spread sheets, database systems etc. These programs are known as system utilities or application programs.
  • 17. Operating System 16 PROCESS MANAGEMENT Current day computer systems allow multiple programs to be loaded into memory and executed concurrently. Process is nothing but a program in execution. A process is the unit of work in a modern time sharing system. A system is a collection of processes: operating system processes executing operating system code and user processes executing user code. By switching CPU between processes, the operating system can make the computer more productive. Overview A batch system executes jobs whereas a time shared system has user programs or tasks. On a single user system, user may be able to run several programs at one time: a word processor, a web browser and an e-mail package. All of these are called processes. The Process A process is a program in execution. A process is more than a program code sometimes known as text section. It also includes the current activity as represented by the value of the program counter and the contents of the processor‟s registers. A process generally also includes the process stack which contains temporary data and a data section which contains global variables. A process may also include a heap which is memory that is dynamically allocated during process run time. Program itself is not a
  • 18. Operating System 17 process, a program is a passive entity such as a file containing a list of instructions stored on disk (called an executable file) whereas process is an active entity with a program counter specifying the next instruction to execute and a set of associated resources. A program becomes a process when an executable file is loaded into memory. Although two processes may be associated with the same program, they are considered two separate execution sequences. Process State As a process executes, it changes state. The state of a process is defined in part by the current activity of that process. Each process may be in one of the following states- New: The process is being created. Running: Instructions are being executed. Waiting: The process is waiting for some event to occur.
  • 19. Operating System 18 Ready: The process is waiting to be assigned to the processor. Terminated: The process has finished execution. Process Control Block Each process is represented in the operating system by a process control block (PCB) also called task control block. It contains many pieces of information associated with a specific process including: Process State: The state may be new, ready, running, waiting, halted etc. Process Number: Unique number which is assigned to a program at time of its execution. Program Counter: The counter indicates the address of the next instruction to be executed for this process. CPU registers: The registers vary in number and type depending on the computer architecture.
  • 20. Operating System 19 CPU scheduling information: This information includes a process priority, pointers to scheduling queues, and other scheduling parameters. Memory management information: This information may include such information as the value of base and limit registers etc. Accounting information: This information includes the amount of CPU and real time used, time limits etc. I/O status information: This information includes the list of I/O devices allocated to the process, etc. Threads Process is a program that performs a single thread of execution. A single thread of control allows the process to perform only one task at one time. Process Scheduling
  • 21. Operating System 20 The objective of multi programming is to have some process running at all times to maximize CPU utilization. The objective of time sharing is to switch the CPU among processes so frequently that users can interact with each program while it is running. To meet these objectives, the process scheduler selects an available process for program execution on the CPU. For a single processer system, there will never be more than one running process. Scheduling Queues Job queue: As processes enter the system, they are put inside the job queue, which consists of all processes in the system. Ready queue: The processes that are residing in main memory and are ready and waiting to execute are kept on a list called the ready queue. This queue is stored as a linked list. A ready queue header contains pointers
  • 22. Operating System 21 to the first and final PCB‟s in the list. Each PCB includes a pointer field that points to the next PCB in the ready queue. Device queue: When a process is allocated the CPU, it executes for a while and eventually quits, is interrupted or waits for the occurrence of a particular event such as the completion of an I/O request. The list of processes waiting for a particular I/O device is called a device queue. Each device has its own device queue. Queuing diagram A common representation for process scheduling is queuing diagram. Each rectangular box represents a queue. Two types of queues are present: ready queue and a set of device queues. Circles represent the resources that serve the queues and the arrows indicate the flow of processes in the system.
  • 23. Operating System 22 A new process is initially put in the ready queue. It waits there until it is selected for execution or is dispatched. Once the process is allocated the CPU and is executing, one of the following events might occur – a) The process could issue and I/O request and then be placed in the I/O queue. b) The process could create a new sub process and wait for the sub process‟s termination. c) The process could be removed forcibly from the CPU as a result of an interrupt and be put back in the ready queue. Schedulers A process migrated among the various scheduling queues throughout its life time. The OS must select for scheduling purposes, processes from these queues and this selection is carried out by scheduler. In a batch system, more processes are submitted than can be executed immediately. These processes are spooled to a mass storage device (disk) where they are kept for later execution. The long term scheduler or job scheduler selects processes from this pool and loads them into memory for execution. The short term scheduler or CPU scheduler selects from among the processes that are ready to execute and allocates the CPU to one of them. The distinction between these two lies in the frequency of execution. The long term scheduler controls the degree of multi programming (the number of processes in memory). Most
  • 24. Operating System 23 processes can be described as either I/O bound or CPU bound. An I/O bound process is one that spends more of its time doing I/O than it spends doing computations. A CPU bound process generates I/O requests infrequently using more of its time doing computations. Long term scheduler must select a good mix of I/O bound and CPU bound processes. A system with best performance will have a combination of CPU bound and I/O bound processes. Some operating systems such as time sharing systems may introduce additional/intermediate level of scheduling. Idea behind medium term scheduler is that sometimes it can be advantageous to remove processes from memory and thus reduce the degree of multiprogramming. Later the process can be reintroduced into memory and its execution can be continued where it left off. This scheme is called swapping. The process is swapped out and is later swapped in by the medium term scheduler. Context switch Interrupts cause the OS to change a CPU from its current task and to run a kernel routine. When an interrupt occurs, the system needs to save the
  • 25. Operating System 24 current context of the process currently running on the CPU so that it can restore that context when its processing is done, essentially suspending the process and then resuming it. The context is represented in the PCB of the process, it includes the value of CPU registers, process state and memory management information. We perform a state save of the current state of the CPU and then state restore to resume operations. Switching the CPU to another process requires performing a state save of the current process and a state restore of a different process. This task is known as context switch. Kernel saves the context of the old process in its PCB and loads the saved context of the new process scheduled to run. Context switch time is pure overhead. Its speed varies from machine to machine depending on the memory speed, the number of registers that must be copied and the existence of special instructions. Context switch times are highly dependent on hardware support. Multithreading Thread is a basic unit of CPU utilization. Support for threads may be provided either at the user level for user threads or by the kernel for kernel threads. User threads are supported above the kernel and are managed without kernel support whereas kernel threads are supported and managed directly by the operating system. Benefits of multi threaded programming are: Responsiveness: Multi threading an interactive application may allow a program to continue running even if part of it is blocked or is
  • 26. Operating System 25 performing a lengthy operation, thereby increasing responsiveness to the user. Resource interaction: Threads share the memory and the resources of the process to which they belong. The benefit of sharing code and data is that it allows an application to have several different threads of activity within the same address space. Economy: Allocating memory and resources for process creation is costly. Because threads share resources of the process to which they belong, it is more economical to create and context switch threads. Utilization of multi processor architecture: The benefits of multi threading can be greatly increased in a multi processor architecture where threads may be running in parallel on different processors. Multi threading on a multi CPU machine increases concurrency. User threads are supported above the kernel and are managed without kernel support whereas kernel threads are supported and managed directly by the operating system. CPU scheduling is the basis of multi programmed operating systems. By switching CPU among processes, the OS can make the computer more productive. On operating systems that support threads, it is kernel level threads and not processes that are scheduled by operating system. But process scheduling and thread scheduling are often used interchangeably.
  • 27. Operating System 26 In a single processor system, only one process can run at a time; others must wait until CPU is free and can be rescheduled. The objective of multi programming is to have some process running at all times to maximize CPU utilization. Under multi programming, several processes are kept in memory at one time. When one process has to wait, the OS takes the CPU away from that process and gives the CPU to another process. As CPU is one of the primary computer resources, its scheduling is central to operating system design. Three common ways of establishing a relationship between user level and kernel level threads are: Many to one model - Maps many user level threads to one kernel thread. Thread management is done by the thread library in user space hence it is efficient but entire process will block if a thread makes a blocking system call. As only one thread can access the kernel at a time, multiple threads are unable to run in parallel on multi processors.
  • 28. Operating System 27 One to one model - Maps each user thread to kernel thread. It allows more concurrency by allowing another thread to run when a thread makes a blocking system call; it also allows multiple threads to run in parallel on multi processors. Disadvantage is that creating a user thread requires creating the corresponding kernel thread. Many to many model - Multiplexes many user level threads to a smaller or equal number of kernel level threads. The number of kernel threads may be specific to either a particular application or a particular machine. Developers can create as many user threads as necessary and the corresponding kernel threads can run in parallel on a multi processor. Also, when a thread performs a blocking system call, the kernel can schedule another thread for execution.
  • 29. Operating System 28 On operating systems that support threads, it is kernel level threads that are being scheduled by operating system. User level threads are managed by thread library. To run on a CPU, user level threads must be mapped to an associated kernel level thread although this mapping may be indirect and may use a light weight process. PROCESS SCHEDULING: Process is an executing program with a single thread of control. Most operating systems provide features enabling a process to contain multiple threads of control. A thread is a basic unit of CPU utilization; it comprises of a thread ID, a program counter, a register set and a stack. It shares with other threads belonging to the same process its code section, data section and other operating system resources such as open files and signals. A traditional or heavy weight process has a single thread of control. CPU – I/O burst cycle: Process execution consists of a cycle of CPU execution and I/O wait. Processes alternate between these two states. Process execution begins with CPU burst followed by an I/O burst and so on. The final CPU burst ends with a system request to terminate execution.
  • 30. Operating System 29 An I/O bound program has many short CPU bursts. A CPU bound program might have a few long CPU bursts. CPU scheduler: Whenever the CPU becomes idle, the operating system must select one of the processes in the ready queue to be executed. The selection process is carried out by the short term scheduler or CPU scheduler. The scheduler selects a process from the processes in memory that are ready to execute and allocates the CPU to that process. The ready queue is not necessarily a first in first out queue. A ready queue can be implemented as a FIFO queue, a priority queue, a tree or an
  • 31. Operating System 30 unordered linked list. All the processes in the ready queue are lined up waiting for a chance to run on the CPU. The records in the queue are process control blocks of the processes. Pre-emptive scheduling: CPU scheduling decisions may take place under the following four conditions- a) When a process switches from the running state to the waiting state b) When a process switches from the running state to the ready state c) When a process switches from the waiting state to the ready state d) When a process terminates When scheduling takes place under conditions 1 and 4, scheduling scheme is non - pre emptive or co-operative. Else it is called pre emptive. Under non pre emptive scheduling, once the CPU has been allocated to a process, the process keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state. Pre emptive scheduling incurs cost associated with access to shared data. Pre emption also affects the design of the operating system kernel. Dispatcher: The dispatcher is the module that gives control of the CPU to the process selected by the short term scheduler. This function involves- a) Switching context
  • 32. Operating System 31 b) Switching to user mode c) Jumping to the proper location in the user program to restart that program Dispatcher should be as fast as possible since it is invoked during every process switch. The time it takes for the dispatcher to stop one process and start another running is called dispatch latency. Scheduling criteria: Different CPU scheduling algorithms have different properties. Criteria for comparing CPU scheduling algorithms- a) CPU utilization: Keep the CPU as busy as possible b) Through put: One measure of work of CPU is the number of processes that are completed per time unit called through put. c) Turnaround time: The interval from the time of submission of a process to the time of completion is the turnaround time. Turnaround time is the sum of the periods spent waiting to get into memory, waiting in the ready queue, executing on the CPU and doing I/O. d) Waiting time: It is the sum of the periods spent waiting in the ready queue. e) Response time: The time it takes for the process to start responding but is not the time it takes to output the response.
  • 33. Operating System 32 It is desirable to maximize CPU utilization and through put and to minimize turnaround time, waiting time and response time. Scheduling algorithms: First Come First Serve: This is the simplest CPU scheduling algorithm. The process that requests the CPU first is allocated the CPU first. The implementation of FCFS is managed with a FIFO queue. When a process enters the ready queue, its PCB is linked onto the tail of the queue. When the CPU is free, it is allocated to the process at the head of the queue. The running process is then removed from the queue. The average waiting time under FCFS is often quite long. The FCFS scheduling algorithm is non pre-emptive. Once the CPU has been allocated to a process, that process keeps the CPU until it releases the CPU either by terminating or by requesting I/O. It is simple, fair, but poor performance. Average queuing time may be long.
  • 34. Operating System 33 Shortest Job First: This algorithm associates with each process the length of the process‟s next CPU burst. When the CPU is available, it is assigned to the process that has the smallest next CPU burst. If the next CPU bursts of two processes are the same, FCFS scheduling is used to break the tie. Priority:
  • 35. Operating System 34 The SJF is a special case of the general priority scheduling algorithm. A priority is associated with each process and CPU is allocated to the process with highest priority. Equal priority processes are scheduled in FCFS order. An SJF algorithm is simply a priority algorithm where the priority is the inverse of the predicted next CPU burst. The larger the CPU burst, the lower the priority. Priorities are generally indicated by some fixed range of numbers usually 0 to 7. Priorities can be defined either internally or externally. Internally defined priorities use some measurable quantity to computer the priority of a process. External priorities are set by criteria outside the operating system. Priority scheduling can be either pre emptive or non pre emptive. When a process arrives at the ready queue, its priority is compared with the priority of the currently running process. A preemptive priority scheduling algorithm will preempt the CPU is the priority of the newly arrived process is higher than the priority of the currently running process. A non preemptive priority scheduling algorithm will put the new process at the head of the ready queue. The major problem with priority scheduling algorithm is indefinite blocking or starvation. A process that is ready to run but waiting for the CPU can be considered blocked. A priority scheduling algorithm can leave some low priority processes waiting indefinitely. A solution to the problem of indefinite blockage of low priority processes is
  • 36. Operating System 35 aging. Aging is a technique of gradually increasing the priority of processes that wait in the system for a long time. Round Robin: The round robin scheduling algorithm is designed for time sharing systems. It is similar to FCFS scheduling but preemption is added to switch between processes. A small unit of time called a time quantum or time slice is defined. A time quantum is generally from 10 to 100 milli seconds. The ready queue is treated as a circular queue. The CPU scheduler goes around the ready queue allocating the CPU to each process for a time interval of up to 1 time quantum. To implement RR scheduling, ready queue is implemented as a FIFO queue. New processes are added to the tail of ready queue. The CPU scheduler picks the first process from the ready queue, sets the timer to interrupt after 1 time quantum and dispatches the process. The process may either have a CPU burst of less than 1 time quantum. Then, the process itself will release the CPU voluntarily. The scheduler will then proceed to the next process in the ready queue. Else if the CPU burst of the currently running process is longer than 1 time quantum, the timer will go off and will cause an interrupt to the operating system. A context switch will be executed and the process will be put at the tail of the ready queue. The CPU scheduler will then select the next process in the ready queue.
  • 37. Operating System 36 In the RR scheduling algorithm, no process is allocated the CPU for more than 1 time quantum in a row. If a process‟s CPU burst exceeds 1 time quantum, that process is preempted and is put back in the ready queue. Thus this algorithm is preemptive. The performance of the RR algorithm depends heavily on the size of time quantum. If the time quantum is extremely large, the RR policy is same as the FCFS policy. If the time quantum is extremely small, the RR approach is called processor sharing. Algorithm evaluation Selection of an algorithm is difficult. The first problem is defining the criteria to be used in selecting an algorithm. Criteria are often defined in terms of CPU utilization, response time or through put. Criteria includes several measures such as-
  • 38. Operating System 37 a) Maximizing CPU utilization under the constraint that the maximum response time is 1 second. b) Maximizing through put such that turnaround time is linearly proportional to total execution time.