0% found this document useful (0 votes)
44 views36 pages

Unit I

The document discusses the key functions and components of an operating system. It begins by defining an operating system and its role in managing computer resources and acting as an interface between software and hardware. It then covers the objectives of operating systems in making computers convenient to use and managing resources efficiently. Finally, it discusses the services provided by operating systems, including program execution, input/output control, and file management.

Uploaded by

no name
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views36 pages

Unit I

The document discusses the key functions and components of an operating system. It begins by defining an operating system and its role in managing computer resources and acting as an interface between software and hardware. It then covers the objectives of operating systems in making computers convenient to use and managing resources efficiently. Finally, it discusses the services provided by operating systems, including program execution, input/output control, and file management.

Uploaded by

no name
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

UNIT-I

Operating System
Operating System lies in the category of system software. It basically
manages all the resources of the computer. An operating system acts as an
interface between the software and different parts of the computer or the
computer hardware. The operating system is designed in such a way that it
can manage the overall resources and operations of the computer. It is a
fully integrated set of specialized programs that handle all the operations of
the computer. It controls and monitors the execution of all other programs
that reside in the computer, which also includes application programs and
other system software of the computer. Examples of the operating system
are Windows, Linux, Mac OS, etc.

Diagram of the operating system:

Objectives:

Let us now see some of the objectives of the operating system, which are:

Convenient to use: One of the objectives is to make the computer system


more convenient to use in an efficient manner.

© 2021– www.geekshelp.online
1. User Friendly: To make the computer system more interactive with a
more convenient interface for the users.
2. To provide easy access to users for using resources by acting as an
intermediary between the hardware and its users.
3. For managing the resources of a computer.
4. Controls and Monitoring: By keeping the track of who is using which
resource, granting resource requests, and mediating conflicting
requests from different programs and users.
5. Providing efficient and fair sharing of resources between the users and
programs.
Characteristics:
Let us now discuss some of the important characteristic features of
operating systems:

 Device Management: The operating system keeps track of all the


devices. So, it is also called the Input / Output controller that decides
which process gets the device, when, and for how much time.
 File Management: It allocates and de-allocates the resources and also
decides who gets the resource.
 Job Accounting: It keeps the track of time and resources used by
various jobs or users.
 Error-detecting Aids: It contains methods that include the production
of dumps, traces, error messages, and other debugging and error-
detecting methods.
 Memory Management: It keeps track of the primary memory, like what
part of it is in use by whom, or what part is not in use, etc. and It also
allocates the memory when a process or program requests it.

© 2021– www.geekshelp.online
 Processor Management: It allocates the processor to a process and
then de-allocates the processor when it is no longer required or the job
is done.
 Control on System Performance: It records the delays between the
request for a service and from the system.
 Security: It prevents unauthorized access to programs and data by
means of passwords or some kind of protection technique.
Types of the operating system:
 Batch Operating System: This type of operating system does not
interact with the computer directly. There is an operator which takes
similar jobs having the same requirements and groups them into
batches.
 Time-sharing operating System: This type of operating system allows
many users to share computer resources. (Max utilization of the
resources).
 Distributed operating System: This type of operating system manages
a group of different computers and makes appear to be a single
computer.
 Network operating system: This type of operating system running on a
server and provides the capability to manage data, users, groups,
security, applications, and other networking functions.
 Real-time operating system: This type of operating system serves real
time system and the time interval required to process and respond to
inputs is very small.

© 2021– www.geekshelp.online
Operating System Services
The operating system provides the programming environment in which a
programmer works on a computer system. The user program requests various
resources through the operating system. The operating system gives several
services to utility programmers and users. Applications access these services
through application programming interfaces or system calls. By invoking
those interfaces, the application can request a service from the operating
system, pass parameters, and acquire the operation outcomes.

Following are the services provided by an operating system

o Program execution
o Control Input/output devices
o Program creation
o Error Detection and Response
o Accounting
o Security and Protection
o File Management
o Communication

Program execution

To execute a program, several tasks need to be performed. Both the


instructions and data must be loaded into the main memory. In addition, input-
output devices and files should be initialized, and other resources must be
prepared. The Operating structures handle these kinds of tasks. The user now
no longer should fear the reminiscence allocation or multitasking or anything.

© 2021– www.geekshelp.online
Control Input/output devices

As there are numerous types of I/O devices within the computer system, and
each I/O device calls for its own precise set of instructions for the operation.
The Operating System hides that info with the aid of presenting a uniform
interface. Thus, it is convenient for programmers to access such devices
easily.

Program Creation

The Operating system offers the structures and tools, including editors and
debuggers, to help the programmer create, modify, and debugging programs.

Error Detection and Response

An Error in a device may also cause malfunctioning of the entire device. These
include hardware and software errors such as device failure, memory error,
division by zero, attempts to access forbidden memory locations, etc. To avoid
error, the operating system monitors the system for detecting errors and
takes suitable action with at least impact on running applications.

While working with computers, errors may occur quite often. Errors may occur in the:

o Input/ Output devices: For example, connection failure in the network,


lack of paper in the printer, etc.
o User program: For example: attempt to access illegal memory locations,
divide by zero, use too much CPU time, etc.
o Memory hardware: For example, Memory error, the memory becomes
full, etc.

© 2021– www.geekshelp.online
To handle these errors and other types of possible errors, the operating
system takes appropriate action and generates messages to ensure correct
and consistent computing.

Accounting

An Operating device collects utilization records for numerous assets and


tracks the overall performance parameters and responsive time to enhance
overall performance. These personal records are beneficial for additional
upgrades and tuning the device to enhance overall performance.

Security and Protection

Operating device affords safety to the statistics and packages of a person and
protects any interference from unauthorized users. The safety feature
counters threats, which are published via way of individuals out of doors the
manage of the running device.

For Example:

When a user downloads something from the internet, that program may
contain malicious code that may harm the already existing programs. The
operating system ensures that proper checks are applied while downloading
such programs.

If one computer system is shared amongst a couple of users, then the various
processes must be protected from another intrusion. For this, the operating
system provides various mechanisms that allow only those processes to use
resources that have gained proper authorization from the operating system.
The mechanism may include providing unique users ids and passwords to
each user.

© 2021– www.geekshelp.online
File management

Computers keep data and information on secondary storage devices like


magnetic tape, magnetic disk, optical disk, etc. Each storage media has its
capabilities like speed, capacity, data transfer rate, and data access methods.

For file management, the operating system must know the types of different
files and the characteristics of different storage devices. It has to offer the
proportion and safety mechanism of documents additionally.

Communication

The operating system manages the exchange of data and programs among
different computers connected over a network. This communication is
accomplished using message passing and shared memory.

System Calls
A system call is a method for a computer program to request a service from
the kernel of the operating system on which it is running. A system call is a
method of interacting with the operating system via programs. A system call
is a request from computer software to an operating system's kernel.

The Application Program Interface (API) connects the operating system's


functions to user programs. It acts as a link between the operating system and
a process, allowing user-level programs to request operating system services.
The kernel system can only be accessed using system calls. System calls are
required for any programs that use resources.

© 2021– www.geekshelp.online
Need of system calls in Operating System

There are various situations where you must require system calls in the
operating system. Following of the situations are as follows:

1. It is must require when a file system wants to create or delete a file.


2. Network connections require the system calls to sending and receiving
data packets.
3. If you want to read or write a file, you need to system calls.
4. If you want to access hardware devices, including a printer, scanner, you
need a system call.
5. System calls are used to create and manage new processes.

Types of System Calls


There are commonly five types of system calls. These are as follows

1. Process Control
2. File Management
3. Device Management
4. Information Maintenance
5. Communication

© 2021– www.geekshelp.online
Now, you will learn about all the different types of system calls one-by-one.

Process Control

Process control is the system call that is used to direct the processes. Some
process control examples include creating, load, abort, end, execute, process,
terminate the process, etc.

File Management

File management is a system call that is used to handle the files. Some file
management examples include creating files, delete files, open, close, read,
write, etc.

Device Management

Device management is a system call that is used to deal with devices. Some
examples of device management include read, device, write, get device
attributes, release device, etc.

Information Maintenance

Information maintenance is a system call that is used to maintain information.


There are some examples of information maintenance, including getting
system data, set time or date, get time or date, set system data, etc.

Communication

Communication is a system call that is used for communication. There are


some examples of communication, including create, delete communication
connections, send, receive messages, etc.

© 2021– www.geekshelp.online
System Programs in Operating System
System Programming can be defined as the act of building Systems
Software using System Programming Languages. According to Computer
Hierarchy, one which comes at last is Hardware. Then it is Operating System,
System Programs, and finally Application Programs. Program Development
and Execution can be done conveniently in System Programs. Some of the
System Programs are simply user interfaces, others are complex. It
traditionally lies between the user interface and system calls.

So here, the user can only view up-to-the System Programs he can’t see
System Calls.
System Programs can be divided into these categories:

1. File Management:
A file is a collection of specific information stored in the memory of a
computer system. File management is defined as the process of
manipulating files in the computer system, its management includes the
process of creating, modifying and deleting files.
 It helps to create new files in the computer system and placing them at
specific locations.

© 2021– www.geekshelp.online
 It helps in easily and quickly locating these files in the computer
system.
 It makes the process of sharing files among different users very easy
and user-friendly.
 It helps to store files in separate folders known as directories.
 These directories help users to search files quickly or to manage files
according to their types of uses.
 It helps users to modify the data of files or to modify the name of files
in directories.
2. Status Information:
Information like date, time amount of available memory, or disk space is
asked by some users. Others providing detailed performance, logging, and
debugging information which is more complex. All this information is
formatted and displayed on output devices or printed. Terminal or other
output devices or files or a window of GUI is used for showing the output
of programs.
3. File Modification:
For modifying the contents of files we use this. For Files stored on disks
or other storage devices, we used different types of editors. For
searching contents of files or perform transformations of files we use
special commands.
4. Programming-Language support:
For common programming languages, we use Compilers, Assemblers,
Debuggers, and interpreters which are already provided to users. It
provides all support to users. We can run any programming language. All
languages of importance are already provided.

© 2021– www.geekshelp.online
5. Program Loading and Execution:
When the program is ready after Assembling and compilation, it must be
loaded into memory for execution. A loader is part of an operating system
that is responsible for loading programs and libraries. It is one of the
essential stages for starting a program. Loaders, relocatable loaders,
linkage editors, and Overlay loaders are provided by the system.
6. Communications:
Virtual connections among processes, users, and computer systems are
provided by programs. Users can send messages to another user on their
screen, User can send e-mail, browsing on web pages, remote login, the
transformation of files from one user to another.

Some examples of system program in O.S. are –


 Windows 10
 Mac OS X
 Ubuntu
 Linux
 Unix
 Android
 Anti-virus
 Disk formatting
 Computer language translators

© 2021– www.geekshelp.online
Process in Operating System
A process is a program in execution which then forms the basis of all
computation. The process is not as same as program code but a lot more than
it. A process is an 'active' entity as opposed to the program which is
considered to be a 'passive' entity. Attributes held by the process include
hardware state, memory, CPU, etc.

Process memory is divided into four sections for efficient working:

 The Text section is made up of the compiled program code, read in


from non-volatile storage when the program is launched.
 The Data section is made up of the global and static variables, allocated
and initialized prior to executing the main.
 The Heap is used for the dynamic memory allocation and is managed via
calls to new, delete, malloc, free, etc.
 The Stack is used for local variables. Space on the stack is reserved for
local variables when they are declared.

© 2021– www.geekshelp.online
The different Process States

Processes in the operating system can be in any of the following states:

 NEW- The process is being created.


 READY- The process is waiting to be assigned to a processor.
 RUNNING- Instructions are being executed.
 WAITING- The process is waiting for some event to occur(such as an I/O
completion or reception of a signal).
 TERMINATED- The process has finished execution.

Process Life Cycle


When a process executes, it passes through different states. These stages
may differ in different operating systems, and the names of these states are
also not standardized.

In general, a process can have one of the following five states at a time.

© 2021– www.geekshelp.online
S.N. State & Description

1 Start

This is the initial state when a process is first started/created.

2 Ready

The process is waiting to be assigned to a processor. Ready processes are


waiting to have the processor allocated to them by the operating system
so that they can run. Process may come into this state after Start state or
while running it by but interrupted by the scheduler to assign CPU to some
other process.

3 Running

Once the process has been assigned to a processor by the OS scheduler,


the process state is set to running and the processor executes its
instructions.

4 Waiting

Process moves into the waiting state if it needs to wait for a resource,
such as waiting for user input, or waiting for a file to become available.

5 Terminated or Exit

Once the process finishes its execution, or it is terminated by the


operating system, it is moved to the terminated state where it waits to be
removed from main memory.

© 2021– www.geekshelp.online
Operations on Processes
Process: A process is an activity of executing a program. Basically, it is a
program under execution. Every process needs certain resources to
complete its task.

Operation on a Process:
The execution of a process is a complex activity. It involves various
operations. Following are the operations that are performed while execution
of a process:

© 2021– www.geekshelp.online
1. Creation:
This the initial step of process execution activity. Process creation means the
construction of a new process for the execution. This might be performed by
system, user or old process itself. There are several events that leads to the
process creation. Some of the such events are following:
 When we start the computer, system creates several background
processes.
 A user may request to create a new process.
 A process can create a new process itself while executing.
 Batch system takes initiation of a batch job.
2. Scheduling/Dispatching:
The event or activity in which the state of the process is changed from ready
to running. It means the operating system puts the process from ready state
into the running state. Dispatching is done by operating system when the
resources are free or the process has higher priority than the ongoing
process. There are various other cases in which the process in running state

© 2021– www.geekshelp.online
is preempted and process in ready state is dispatched by the operating
system.
3. Blocking:
When a process invokes an input-output system call that blocks the process
and operating system put in block mode. Block mode is basically a mode
where process waits for input-output. Hence on the demand of process
itself, operating system blocks the process and dispatches another process
to the processor. Hence, in process blocking operation, the operating system
puts the process in ‘waiting’ state.
4. Preemption:
When a timeout occurs that means the process hadn’t been terminated in
the allotted time interval and next process is ready to execute, then the
operating system preempts the process. This operation is only valid where
CPU scheduling supports preemption. Basically this happens in priority
scheduling where on the incoming of high priority process the ongoing
process is preempted. Hence, in process preemption operation, the operating
system puts the process in ‘ready’ state.
5. Termination:
Process termination is the activity of ending the process. In other words,
process termination is the relaxation of computer resources taken by the
process for the execution. Like creation, in termination also there may be
several events that may lead to the process termination. Some of them are:
 Process completes its execution fully and it indicates to the OS that it has
finished.
 Operating system itself terminates the process due to service errors.
 There may be problem in hardware that terminates the process.
 One process can be terminated by another process.

© 2021– www.geekshelp.online
Inter Process Communication
In general, Inter Process Communication is a type of mechanism usually
provided by the operating system (or OS). The main aim or goal of this
mechanism is to provide communications in between several processes. In
short, the intercommunication allows a process letting another process know
that some event has occurred.

Let us now look at the general definition of inter-process communication,


which will explain the same thing that we have discussed above.

Definition

"Inter-process communication is used for exchanging useful information


between numerous threads in one or more processes (or programs)."

To understand inter process communication, you can consider the following


given diagram that illustrates the importance of inter-process
communication:

© 2021– www.geekshelp.online
Role of Synchronization in Inter Process Communication

It is one of the essential parts of inter process communication. Typically, this


is provided by interprocess communication control mechanisms, but
sometimes it can also be controlled by communication processes.

These are the following methods that used to provide the synchronization:

1. Mutual Exclusion
2. Semaphore
3. Barrier
4. Spinlock

Mutual Exclusion:

It is generally required that only one process thread can enter the critical
section at a time. This also helps in synchronization and creates a stable state
to avoid the race condition.

Semaphore:

Semaphore is a type of variable that usually controls the access to the shared
resources by several processes. Semaphore is further divided into two types
which are as follows:

1. Binary Semaphore
2. Counting Semaphore

© 2021– www.geekshelp.online
Barrier:

A barrier typically not allows an individual process to proceed unless all the
processes does not reach it. It is used by many parallel languages, and
collective routines impose barriers.

Spinlock:

Spinlock is a type of lock as its name implies. The processes are trying to
acquire the spinlock waits or stays in a loop while checking that the lock is
available or not. It is known as busy waiting because even though the process
active, the process does not perform any functional operation (or task).

Approaches to Inter-process Communication

We will now discuss some different approaches to inter-process


communication which are as follows:

© 2021– www.geekshelp.online
These are a few different approaches for Inter- Process Communication:

1. Pipes
2. Shared Memory
3. Message Queue
4. Direct Communication
5. Indirect communication
6. Message Passing
7. FIFO

To understand them in more detail, we will discuss each of them individually.

Pipe

The pipe is a type of data channel that is unidirectional in nature. It means that
the data in this type of data channel can be moved in only a single direction at
a time. Still, one can use two-channel of this type, so that he can able to send
and receive data in two processes. Typically, it uses the standard methods for
input and output. These pipes are used in all types of POSIX systems and in
different versions of window operating systems as well.

Shared Memory

It can be referred to as a type of memory that can be used or accessed by


multiple processes simultaneously. It is primarily used so that the processes
can communicate with each other. Therefore the shared memory is used by
almost all POSIX and Windows operating systems as well.

Message Queue

© 2021– www.geekshelp.online
In general, several different messages are allowed to read and write the data
to the message queue. In the message queue, the messages are stored or stay
in the queue unless their recipients retrieve them. In short, we can also say
that the message queue is very helpful in inter-process communication and
used by all operating systems.

To understand the concept of Message queue and Shared memory in more


detail, let's take a look at its diagram given below:

Message Passing

It is a type of mechanism that allows processes to synchronize and


communicate with each other. However, by using the message passing, the
processes can communicate with each other without restoring the hared
variables.

Usually, the inter-process communication mechanism provides two


operations that are as follows:

o send (message)
o received (message)

© 2021– www.geekshelp.online
Note: The size of the message can be fixed or variable.

Direct Communication

In this type of communication process, usually, a link is created or established


between two communicating processes. However, in every pair of
communicating processes, only one link can exist.

Indirect Communication

Indirect communication can only exist or be established when processes


share a common mailbox, and each pair of these processes shares multiple
communication links. These shared links can be unidirectional or bi-
directional.

FIFO

It is a type of general communication between two unrelated processes. It can


also be considered as full-duplex, which means that one process can
communicate with another process and vice versa.

Some other different approaches


o Socket

It acts as a type of endpoint for receiving or sending the data in a network.


It is correct for data sent between processes on the same computer or
data sent between different computers on the same network. Hence, it
used by several types of operating systems.

© 2021– www.geekshelp.online
o File:

A file is a type of data record or a document stored on the disk and can be
acquired on demand by the file server. Another most important thing is
that several processes can access that file as required or needed.

o Signal:

As its name implies, they are a type of signal used in inter process
communication in a minimal way. Typically, they are the massages of
systems that are sent by one process to another. Therefore, they are not
used for sending data but for remote commands between multiple
processes.

Usually, they are not used to send the data but to remote commands in
between several processes.

Why we need inter-process communication

There are numerous reasons to use inter-process communication for sharing


the data. Here are some of the most important reasons that are given below:

o It helps to speedup modularity


o Computational
o Privilege separation
o Convenience
o Helps operating system to communicate with each other and
synchronize their actions as well.

© 2021– www.geekshelp.online
CPU Scheduling Criteria
Different CPU scheduling algorithms have different properties and the
choice of a particular algorithm depends on the various factors. Many
criteria have been suggested for comparing CPU scheduling algorithms.
The criteria include the following:

1. CPU Utilization:
The main objective of any CPU scheduling algorithm is to keep the CPU as
busy as possible. Theoretically, CPU utilization can range from 0 to 100 but in
a real-time system, it varies from 40 to 90 percent depending on the load
upon the system.
2. Throughput:
A measure of the work done by CPU is the number of processes being
executed and completed per unit time. This is called throughput. The
throughput may vary depending upon the length or duration of processes.
3. Turnaround Time:
For a particular process, an important criteria is how long it takes to execute
that process. The time elapsed from the time of submission of a process to
the time of completion is known as the turnaround time. Turn-around time is
the sum of times spent waiting to get into memory, waiting in ready queue,
executing in CPU, and waiting for I/O.
4. Waiting Time:
A scheduling algorithm does not affect the time required to complete the
process once it starts execution. It only affects the waiting time of a process
i.e. time spent by a process waiting in the ready queue.
5. Response time:
In an interactive system, turn-around time is not the best criteria. A process
may produce some output fairly early and continue computing new results

© 2021– www.geekshelp.online
while previous results are being output to the user. Thus another criteria is
the time taken from submission of the process of request until the first
response is produced. This measure is called response time.

There are various CPU Scheduling algorithms such as-


 First Come First Served (FCFS)
 Shortest Job First (SJF)
 Longest Job First (LJF)
 Priority Scheduling
 Round Robin (RR)
 Shortest Remaining Time First (SRTF)
 Longest Remaining Time First (LRTF)

What is CPU Scheduling?


CPU Scheduling is a process of determining which process will own CPU for
execution while another process is on hold. The main task of CPU scheduling is
to make sure that whenever the CPU remains idle, the OS at least select one of
the processes available in the ready queue for execution. The selection
process will be carried out by the CPU scheduler. It selects one of the
processes in memory that are ready for execution.

© 2021– www.geekshelp.online
Types of CPU Scheduling
Here are two kinds of Scheduling methods:

Preemptive Scheduling

In Preemptive Scheduling, the tasks are mostly assigned with their priorities.
Sometimes it is important to run a task with a higher priority before another
lower priority task, even if the lower priority task is still running. The lower
priority task holds for some time and resumes when the higher priority task
finishes its execution.

Non-Preemptive Scheduling

In this type of scheduling method, the CPU has been allocated to a specific
process. The process that keeps the CPU busy will release the CPU either by
switching context or terminating. It is the only method that can be used for
various hardware platforms. That’s because it doesn’t need special hardware
(for example, a timer) like preemptive scheduling.

When scheduling is Preemptive or Non-Preemptive?


To determine if scheduling is preemptive or non-preemptive, consider these
four parameters:

1. A process switches from the running to the waiting state.


2. Specific process switches from the running state to the ready state.

© 2021– www.geekshelp.online
3. Specific process switches from the waiting state to the ready state.
4. Process finished its execution and terminated.

Only conditions 1 and 4 apply, the scheduling is called non- preemptive.

All other scheduling are preemptive.

Important CPU scheduling Terminologies

 Burst Time/Execution Time: It is a time required by the process to


complete execution. It is also called running time.
 Arrival Time: when a process enters in a ready state
 Finish Time: when process complete and exit from a system
 Multiprogramming: A number of programs which can be present in
memory at the same time.
 Jobs: It is a type of program without any kind of user interaction.
 User: It is a kind of program having user interaction.
 Process: It is the reference that is used for both job and user.
 CPU/IO burst cycle: Characterizes process execution, which alternates
between CPU and I/O activity. CPU times are usually shorter than the
time of I/O.

CPU Scheduling Criteria


A CPU scheduling algorithm tries to maximize and minimize the following:

© 2021– www.geekshelp.online
Maximize:

CPU utilization: CPU utilization is the main task in which the operating system
needs to make sure that CPU remains as busy as possible. It can range from 0
to 100 percent. However, for the RTOS, it can be range from 40 percent for
low-level and 90 percent for the high-level system.

Throughput: The number of processes that finish their execution per unit
time is known Throughput. So, when the CPU is busy executing the process, at
that time, work is being done, and the work completed per unit time is called
Throughput.

Minimize:

Waiting time: Waiting time is an amount that specific process needs to wait in
the ready queue.

Response time: It is an amount to time in which the request was submitted


until the first response is produced.

© 2021– www.geekshelp.online
Turnaround Time: Turnaround time is an amount of time to execute a
specific process. It is the calculation of the total time spent waiting to get into
the memory, waiting in the queue and, executing on the CPU. The period
between the time of process submission to the completion time is the
turnaround time.

Interval Timer
Timer interruption is a method that is closely related to preemption. When a
certain process gets the CPU allocation, a timer may be set to a specified
interval. Both timer interruption and preemption force a process to return the
CPU before its CPU burst is complete.

Most of the multi-programmed operating system uses some form of a timer


to prevent a process from tying up the system forever.

What is Dispatcher?
It is a module that provides control of the CPU to the process. The Dispatcher
should be fast so that it can run on every context switch. Dispatch latency is
the amount of time needed by the CPU scheduler to stop one process and
start another.

Functions performed by Dispatcher:

 Context Switching
 Switching to user mode
 Moving to the correct location in the newly loaded program.

© 2021– www.geekshelp.online
Types of CPU scheduling Algorithm
There are mainly six types of process scheduling algorithms

1. First Come First Serve (FCFS)


2. Shortest-Job-First (SJF) Scheduling
3. Shortest Remaining Time
4. Priority Scheduling
5. Round Robin Scheduling
6. Multilevel Queue Scheduling

Scheduling Algorithms

First Come First Serve


First Come First Serve is the full form of FCFS. It is the easiest and most simple
CPU scheduling algorithm. In this type of algorithm, the process which
requests the CPU gets the CPU allocation first. This scheduling method can be
managed with a FIFO queue.

© 2021– www.geekshelp.online
As the process enters the ready queue, its PCB (Process Control Block) is
linked with the tail of the queue. So, when CPU becomes free, it should be
assigned to the process at the beginning of the queue.

Characteristics of FCFS method:

 It offers non-preemptive and pre-emptive scheduling algorithm.


 Jobs are always executed on a first-come, first-serve basis
 It is easy to implement and use.
 However, this method is poor in performance, and the general wait time
is quite high.

Shortest Remaining Time


The full form of SRT is Shortest remaining time. It is also known as SJF
preemptive scheduling. In this method, the process will be allocated to the
task, which is closest to its completion. This method prevents a newer ready
state process from holding the completion of an older process.

Characteristics of SRT scheduling method:

 This method is mostly applied in batch environments where short jobs


are required to be given preference.
 This is not an ideal method to implement it in a shared system where the
required CPU time is unknown.
 Associate with each process as the length of its next CPU burst. So that
operating system uses these lengths, which helps to schedule the
process with the shortest possible time.

© 2021– www.geekshelp.online
Priority Based Scheduling
Priority scheduling is a method of scheduling processes based on priority. In
this method, the scheduler selects the tasks to work as per the priority.

Priority scheduling also helps OS to involve priority assignments. The


processes with higher priority should be carried out first, whereas jobs with
equal priorities are carried out on a round-robin or FCFS basis. Priority can be
decided based on memory requirements, time requirements, etc.

Round-Robin Scheduling
Round robin is the oldest, simplest scheduling algorithm. The name of this
algorithm comes from the round-robin principle, where each person gets an
equal share of something in turn. It is mostly used for scheduling algorithms in
multitasking. This algorithm method helps for starvation free execution of
processes.

Characteristics of Round-Robin Scheduling

 Round robin is a hybrid model which is clock-driven


 Time slice should be minimum, which is assigned for a specific task to be
processed. However, it may vary for different processes.
 It is a real time system which responds to the event within a specific
time limit.

Shortest Job First


SJF is a full form of (Shortest job first) is a scheduling algorithm in which the
process with the shortest execution time should be selected for execution
next. This scheduling method can be preemptive or non-preemptive. It

© 2021– www.geekshelp.online
significantly reduces the average waiting time for other processes awaiting
execution.

Characteristics of SJF Scheduling

 It is associated with each job as a unit of time to complete.


 In this method, when the CPU is available, the next process or job with
the shortest completion time will be executed first.
 It is Implemented with non-preemptive policy.
 This algorithm method is useful for batch-type processing, where
waiting for jobs to complete is not critical.
 It improves job output by offering shorter jobs, which should be
executed first, which mostly have a shorter turnaround time.

Multiple-Level Queues Scheduling


This algorithm separates the ready queue into various separate queues. In this
method, processes are assigned to a queue based on a specific property of
the process, like the process priority, size of the memory, etc.

However, this is not an independent scheduling OS algorithm as it needs to


use other types of algorithms in order to schedule the jobs.

Characteristic of Multiple-Level Queues Scheduling:

 Multiple queues should be maintained for processes with some


characteristics.
 Every queue may have its separate scheduling algorithms.
 Priorities are given for each queue.

© 2021– www.geekshelp.online
The Purpose of a Scheduling algorithm
Here are the reasons for using a scheduling algorithm:

 The CPU uses scheduling to improve its efficiency.


 It helps you to allocate resources among competing processes.
 The maximum utilization of CPU can be obtained with multi-
programming.
 The processes which are to be executed are in ready queue.

Connect with Geeks Help Team

Website: Geeks Help


Linkedin: Raju Sheoran
Instagram: Raju Sheoran

© 2021– www.geekshelp.online

You might also like