Process Management
Operating System
• The computer system comprises of a • While using the application software,
functional set of hardware, software, the user uses the storage of a
user and data. computer to store a document on the
• Hardware consists of the components hard disk, to execute a command on
of computer like memory, processor, the CPU, to retrieve a document from
storage devices, and Input / Output a peripheral device or to print
devices. document on printer.
• The software may be of different • For using the hardware, there is a
kinds: application software and need for software that interacts with
system software. both the hardware and the
application software.
• The user uses the application software • Operating system (OS) is the software
to perform various tasks, for example, that provides an interface between
the user uses word processing the computer hardware, and the
software for document preparation. application programs or users
OBJECTIVES OF OPERATING SYSTEM
• Operating system is system • OS has two main objectives
software that controls and • (1) to make the computer system
coordinates the use of hardware convenient and easy to use, for the
among the different application user.
software and users. • (2) to use the computer hardware in
an efficient way, by handling the
• OS intermediates between the user details of the operations of the
of computer and the computer hardware.
hardware. how?
• The user gives a command and the By managing the communication between different
devices, controlling the sequence and execution of
OS translates the command into a processes, allocating space on hard disk, providing
form that the machine can error handling procedures etc. OS supervises and
manages the hardware of the computer.
understand and execute.
FUNCTIONS OF OS
• Operating system is a large and
complex software consisting of
several components.
• Each component of the
operating system has its own set
of defined inputs and outputs.
• Different components of OS
perform specific tasks to provide
the overall functionality of the
operating system.
Main functions of the operating system are as
follows:
• Process Management: The process management • Device Management: The device management
activities handled by the OS are (1) control access tasks handled by OS are (1) open, close and write
to shared resources like file, memory, I/O and CPU, device drivers, and (2) communicate, control and
(2) control execution of applications, (3) create, monitor the device driver.
execute and delete a process (system process or
user process), (4) cancel or resume a process (5) • Protection and Security: OS protects the resources
schedule a process, and (6) synchronization, of system. User authentication, file attributes like
communication and deadlock handling for read, write, encryption, and back-up of data are
processes. used by OS to provide basic protection.
• Memory Management: The activities of memory • User Interface or Command Interpreter: Operating
management handled by OS are: (1) allocate system provides an interface between the
memory, (2) free memory, (3) re-allocate memory computer user and the computer hardware. The
to a program when a used block is freed, and (4) user interface is a set of commands or a graphical
keep track of memory usage. user interface via which the user interacts with the
applications and the hardware.
• File Management: The file management tasks
include (1) create and delete both files and
directories, (2) provide access to files, (3) allocate
space for files, (4) keep back-up of files, and (5)
secure files.
PROCESS MANAGEMENT
• A process is a program in a state of • The allocation of resources required by a
execution. It is a unit of work for the process is made during process creation and
operating system. process execution.
• A process can be created, executed, and • A process changes its state as it is executed.
stopped. In contrast, a program is always The various states that a process changes
static and does not have any state. during execution are as follows
• A program may have two or more processes
running. A process and a program are, thus,
two different entities.
• To accomplish a task, a process needs to have
access to different system resources like I/O
devices, CPU, memory etc.
• The process management function of an
operating system handles allocation of
resources to the processes in an efficient
manner.
Process States
• New: process is in a new state
when it is created
• Ready: process is in ready state
when it is waiting for a processor
• Running: process is in running
state if processor is executing the
process
• Waiting (Blocked): process is in
waiting state when it waits for
some event to happen (I/O etc)
• Terminated: process that has
finished execution is in terminated
state.
• A system consists of collection of • OS mainly handles the execution
processes: of user code, though it may also
• (1) system process that execute handle various system
system code. processes.
• (2) user process that execute user • The concurrent execution of the
code.
process requires process
synchronization and CPU
scheduling.
CPU Scheduling
• CPU or processor is one of the primary • Scheduler is a component of the
computer resources. operating system that is responsible
• All computer resources like I/O, for scheduling transition of processes.
memory, and CPU are scheduled for • At any one time, only one process can
use. be in running state and the rest are in
• In a multiprogramming systems the ready or waiting state.
processor executes multiple processes • The scheduler assigns the processor
by switching the CPU among the to different processes in a manner so
processes, so that no user has to wait that no one process is kept waiting for
for long for a program to execute. long.
• To enable running of several
concurrent processes, the processor
time has to be distributed amongst all
the processes efficiently.
Major types of CPU Scheduling:
• In pre-emptive scheduling, a • In non-preemptive scheduling, the
running process may be processor executes a process till
interrupted by another process termination without any
that needs to execute. interruption.
• Pre-emption allows the operating • Hence the system resources are
system to interrupt the executing not used efficiently.
task and handle any important task
that requires immediate action.
• In pre-emptive scheduling, the
system resources are used
efficiently.
Different CPU scheduling algorithms that are used to
schedule the processes.
• First Come First Served (FCFS)
Scheduling:
• As the name says, the process that
requests for the CPU first, gets the CPU
first.
• A queue is maintained for the processes
requesting the CPU.
• The process first in the queue is allocated
the CPU first.
• FCFS scheduling is non-pre-emptive.
• The drawback of this scheduling
algorithm is that the process that is
assigned to the CPU may take long time
to complete, keeping all other processes
waiting in the queue, even if they require
less CPU time.
• Shortest Job First (SJF)
Scheduling:
• The process that requires the least
CPU time is allocated the CPU first.
• SJF scheduling is non-pre-emptive.
• The drawback of this scheduling is
that a process that requires more
CPU time may have to wait for
long time, since processes
requiring less CPU time will be
assigned the CPU first.
• Round Robin (RR) Scheduling:
• It is designed for time-sharing systems.
• RR scheduling is pre-emptive.
• In this scheduling, a small quantum of
time (10—100 ms) is defined, and each
process in the queue is assigned the CPU
for this quantum of time circularly.
• New processes are added at the tail of
the queue and the process that has
finished execution is removed from the
queue.
• RR scheduling overcomes the
disadvantage of FCFS and SJF scheduling.
• A process does not have to wait for long,
if it is not the first one in the queue, or, if
it requires CPU for a long period of time.