0% found this document useful (0 votes)
4 views171 pages

OS Course Pack

The document outlines the course pack for the Operating Systems course (Course Code: 301) for BCA students in the third semester of the academic year 2023-24 at Bharati Vidyapeeth Institute of Management and Research. It includes details on course objectives, outcomes, content structure, reference materials, and evaluation methods. The course aims to provide students with a comprehensive understanding of operating systems, including process management, storage management, and file systems.

Uploaded by

shadowprivy
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)
4 views171 pages

OS Course Pack

The document outlines the course pack for the Operating Systems course (Course Code: 301) for BCA students in the third semester of the academic year 2023-24 at Bharati Vidyapeeth Institute of Management and Research. It includes details on course objectives, outcomes, content structure, reference materials, and evaluation methods. The course aims to provide students with a comprehensive understanding of operating systems, including process management, storage management, and file systems.

Uploaded by

shadowprivy
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

COURSE PACK

Course Title: - OPERATING SYSTEMS


(CBCS– Revised Syllabus w.e.f.-Year 2022 –2023)

COURSE CODE : 301


COURSE : BCA
SEMESTER : III
YEAR : 2023-24

Course Instructor: Ms. Kanika Vij


Dr. Mansi Agnihotri
Ms. Ankita Gulati

Course Leader: Ms. Kanika Vij

Dr. Ajay Sahni/


Dr. Ajay Kumar Dr. Daljeet Singh Bawa Dr. Yamini Agarwal
Program Coordinator Forwarded by: HOD - BCA Approved by: Director

Bharati Vidyapeeth (Deemed to be University),


Institute of Management & Research, New Delhi
An ISO 9001: 2015 & 14001:2015 Certified Institute
A-4, PaschimVihar, New Delhi-110063(Ph:011-25284396,25285808, Fax No. 011-25286442)

Note: “Strictly for Internal academic use only”


BVIMR SNAPSHOT

Established in 1992, Bharati Vidyapeeth (Deemed to be University) Institute of Management


and Research (BVIMR), New Delhi focuses on imbibing the said values across various
stakeholders through adequate creation, inclusion, and dissemination of knowledge in
management education. The institute has over the past few years emerged in the lead with a
vision of Leadership in professional education through innovation and excellence. This
excellence is sustained by consistent value enhancement and initiation of value-added academic
processes in institute’s academic systems. Based on the fabulous architecture and layout on the
lines of Nalanda Vishwa Vidyalaya, the institute is a scenic marvel of lush green landscape
with modern interiors. The Institute which is ISO 9001:2015 certified is under the ambit of
Bharati Vidyapeeth University (BVU), Pune as approved by Govt. of India on the
recommendation of UGC under Section 3 of UGC Act vide its letter notification No. F. 9 – 16 /
2004 – U3 dated 25th February 2005. Strategically located in West Delhi on the main Rohtak
Road, BVIMR, New Delhi has splendid layout on sprawling four acres of plot with 'state-of-art'
facilities with all classrooms, Library Labs, Auditorium etc., that are fully air-conditioned. The
Institute that has an adjacent Metro station “Paschim Vihar (East)”, connects the entire Delhi
and NCR. We nurture our learners to be job providers rather than job seekers. This is resorted
to by fostering the skill and enhancement of knowledge base of our students through various
extracurricular, co-curricular and curricular activities by our faculty, who keep themselves
abreast by various research and FDPs and attending Seminars/Conferences. The Alumni has a
key role here by inception of SAARTHI Mentorship program who update and create
professional environment for learners’ centric academic ambiance and bridging industry
academia gap. Our faculty make distinctive contribution not only to students but to Academia
through publications, seminars, conferences apart from quality education. We also believe in
enhancing corporate level interaction including industrial projects, undertaken by our students
under continuous guidance of our faculty. These form the core of our efforts which has resulted
in being one of the premier institutes of management. At BVIMR, we are imparting quality
education in management at Doctorate, Postgraduate and Undergraduate levels.

*********
Ms. Kanika Vij
Mobile: 91-9810205026
She is currently working as a visiting faculty at with Bharati Vidyapeeth Institute of
Management and Research, Delhi (constituent unit of Bharati Vidyapeeth (deemed to be
University) Pune,University ranked in top 70 + band by NIRF.

She has 10 year of teaching experience in Computer Science/IT Subjects of B. Tech (CSE/IT),
BCA, MCA and [Link] has done [Link](CSE) and B,Tech(IT). She has also done
Diploma in Medical Electronics. She is Gold Medalist in [Link] (for highest academic
standing at institute level). She has published several research papers in international journals
of repute.

Dr. Mansi Agnihotri


Mobile M-91-9953871988
E-Mail magnihotri93@[Link]

Experience and Accomplishments


Dr. Mansi Agnihotri earned her Ph.D. in March 2024 from the University School of
Information, Communication and Technology (USICT), Guru Gobind Singh Indraprastha
University (GGSIPU). Her thesis, titled "A New Metric to Identify Critically Affected Classes
and Improving Their Quality Through Refactoring," presents a novel approach to software
quality. She worked as a full-time research scholar at USICT, GGSIPU. She qualified UGC
NET-JRF (DEC 2018) and availed UGC JRF and SRF during her Ph.D. She holds a Master’s
degree in Computer Applications.
She has a good experience of research and has published 6 research papers with SCIE, ESCI,
Scopus indexing and has presented her work at 2 international conferences. She has 4 years of
experience of teaching as a research scholar. She has been a part of organizing team for
different Faculty Development Programme (FDP’s) conducted at USIC&T, GGSIPU.
Subjects Taught
Algorithm Analysis and Design (ADA), Data Structures (DS), C/C++, Object-Oriented
Software Engineering (OOSE), Object-Oriented Analysis and Design (OOAD), Software
Testing (Lab), Advance HTML with JavaScript and CSS.

Ms. Ankita Gulati


Mobile: 9555538440
E-Mail: ankitagulati15@[Link]

Experience and Accomplishments


In her career of 10+ years, She has 1+ Years of experience a designer and 9+ Years of
experience in Teaching.
Skill Sets
 Operating Systems: Windows.
 Databases: Oracle8i & 9i, MS Access, SQL Server.
 Programming Languages: C, C with Data structure, C++, C++ with Data structure,
Java,.Net
 System Concepts: Management information system, Software Engineering, OOAD,
Software testing, fundamentals of internet ,Information Security etc,
TABLE OF CONTENT
Sr. No Contents PAGE NO
1 Course Objectives, Course Outcomes, Course Overview 1

2 Course Plan 2-3

3 Reference Books, Online Resources, MOOCs 3

4 Program Outcomes, Course Outcomes, CO/PO 4-7


Mapping, Internal Assessments, Attendance Policy
5 Session Plan 8-10

6 Unit 1: Introduction to Operating System:


12
 Definition and concept of OS
 History of OS
 Importance and function of Operating system.
 Types of OS
 Views-command language users view, system
call users view structure of OS
 Command line interface, GUI, system calls

7 Unit 2: Process Management:


36
 Process concept
 Process Control Block
 process states and its transitions
 context switch
 OS services for Process management
 scheduling and types of schedulers
 scheduling algorithm
8 Unit 3: Storage Management:
69
 Basic concept of storage management
 logical and physical address space
 swapping
 contiguous allocation, non-contiguous allocation,
fragmentation
 segmentation
 paging, demand paging, virtual memory
 page replacement algorithms
 design issue of paging and thrashing

9 Unit 4: Inter-process communication and synchronization


81
 Mutual Exclusion
 Semaphore
 Busy-wait Implementation
 characteristics of semaphore
 queuing implementation of semaphore
 producer consumer problem
 Critical region and conditional critical area.
 Deadlock
10 Unit 5 : File Systems and Input/output System :
96
 Files-basic concept
 file attributes, operations
 file types, file structure, access methods
 Directory- structure-single level directory system
 Directory system
 Principles of I/O hardware
 I/O devices, device controller
 DMA, Principles of I/O software- goals,
interrupt handler
 Device driver.
 Mass storage structure-disk structure
 disk scheduling
11 Practice Questions
109

12 MCQ
112

12 Previous year question papers


135

13 Research Paper
155
Course Number Course Name L-T-P- Credits Year of Introduction
301 Operating Systems 3L-1T-0P-=3C 2022

Course Objectives:

• To acquire knowledge regarding structure and working of the major operating system
components
 To learn and apply different process and memory scheduling algorithms and synchronization
techniques to achieve better performance of computer system.
 To understand structure and organization of file system

Expected Outcome:

This COURSE focuses the concept of different types of operating systems, the concept of process.
The concept of CPU scheduling, deadlock Explain File Concepts, Access Methods, Directory
Structure, Protection, File System Structure, Allocation Methods, Free Space Management

Course Overview:

This course gives you general understanding that how a computer works. This includes the
concepts related to computer system architecture and key functions of operating system to manage
the hardware resources.
It focuses on the basic principles of Operating systems, Process management, Memory
management, Input output management and file management. This course also covers the concepts
of mutual exclusion and various attempts/ algorithms to solve this problem.
operating System, History of OS, Os Types, Operating System Structures – Command interpreter
Systems, Operating System Services, Systems Calls, System Programs
Process Concept, Process Control Block(PCB), Process Scheduling, CPU – Scheduling – Basic
Concepts, Scheduling Algorithms – FIFO, RR, SJF, Multi Level, Multi Level Feedback
concept of Logical and Physical Address Space, Swapping, Contiguous Allocation, Paging,
Segmentation, Virtual Memory- Demand Paging, Page Replacement, Page Replacement
Algorithms, Allocation of Frames, Thrashing and Demand Segmentation.
concept of Need of inter process communication, Mutual exclusion, Semaphore Definition, Busy
wait implementation, Characteristics of Semaphore, Queuing Implementation of Semaphore,
Producer Consumer Problem, Critical region and conditional critical region.
concept of Conditions to occur the deadlock, Reusable and consumable resources, Deadlock
prevention, Deadlock Avoidance, Resource Request, Resource Release, Detection and recovery.
File Concepts, Access Methods, Directory Structure, Protection, File System Structure, Allocation
Methods, Free Space Management.
Overview of I/O Systems, I/O Interface, Secondary Storage Structure- Disk Structure, Disk
Scheduling, Case Study:-UNIX, LINUX, WINDOWS Operating System and Overview of
ANDROID Operating System

1|Page For Internal Circulation


Course Plan:

UNIT Contents
1 Introduction to Operating System:
Definition and concept of OS, History of OS,
Importance and function of Operating systems.
Types of OS-Batch System, timesharing,
Multitasking, multiprogramming,
multiprocessing, online operating system, real
time, distributed operating system. Views-
command language users view, system call
users view, structure of OSsimple, monolithic
system and layered system, client server model.
User operating-system interface: command line
interface, GUI, system calls.
2 Process Management:
Process concept, Process Control Block,
process states and its transitions, context
switch, OS services for Process management,
scheduling and types of schedulers, scheduling
algorithm-First come first served, shortest job
first, shortest remaining time next, time slice
scheduling, prioritybased scheduling,
multilevel queue, multilevel queue with
feedback
3 Storage Management:
Basic concept of storage management, logical
and physical address space, swapping,
contiguous s allocation, noncontiguous
allocation, fragmentation, segmentation,
paging, demand paging ,virtual memory, page
replacement algorithms-FIFO, Optimal page
replacement algorithm, least recently page
replacement algorithm, clock page replacement
algorithm, design issue of paging, thrashing
4 Inter-process communication and
synchronization
Need, Mutual Exclusion, Semaphore, Busy-
wait Implementation, characteristics of
semaphore, queuing implementation of
semaphore, producer consumer problem,
critical region and conditional critical area.
What is deadlock? Conditions to occur the
deadlock, deadlock prevention, deadlock
avoidance- banker‘s algorithm. resource
2|Page For Internal Circulation
request, resource release.

5 File Systems and Input/output System:


File System : Files-basic concept, file
attributes, operations, file types, file structure,
access methods, Directory- structuresingle
level directory system, two level directory
system, hierarchical directory system, directory
operations, protection, security, allocation
method. Input/output System:  Principles of
I/O hardware, I/O devices, device controller,
DMA, Principles of I/O software- goals,
interrupt handler, device driver. Mass storage
structure-disk structure, disk scheduling
(FCFS, SSTF, SCAN, LOOK, C- SCAN, C-
LOOK) 

Reference Books:

• Operating System Concepts, SilberSchatz, Galvin, Gagne, 11th Edition, Wiley Publication
• Operating systems Concepts and Design, Milan Milenkovic, 2nd Edition, McGraw Hill Education
India
• Operating Systems Design and Implementation, Andrew Tanenbaum and Albert Woodhull, 3rd
Edition, Pearson

Online Resources:

1. [Link]
2. [Link]
3. [Link]
4. [Link]

MOOCs:

1. NPTEL/ Swayam
2. [Link]
3. [Link]

3|Page For Internal Circulation


Programme Outcomes (POs):
On completion of BCA (Honors) Four Year Degree Programme the expected programme outcomes
that a student should be able to demonstrate are the following:

PO1. Computational Knowledge: Understand and apply mathematical foundation,


computing and domain knowledge for the conceptualization of computing models from
defined problems.
PO2. Problem Analysis: Ability to identify, critically analyze and formulate complex
computing problems using fundamentals of computer science and application domains.
PO3. Design / Development of Solutions: Ability to transform complex business
scenarios and contemporary issues into problems, investigate, understand and propose
integrated solutions using emerging technologies.
PO4. Conduct Investigations of Complex Computing Problems: Ability to devise and
conduct experiments, interpret data and provide well informed conclusions.
PO5. Modern Tool Usage: Ability to select modern computing tools, skills and
techniques necessary for innovative software solutions
PO6. Professional Ethics: Ability to apply and commit professional ethics and cyber
regulations in a global economic environment.
PO7. Life-long Learning: Recognize the need for and develop the ability to engage in
continuous learning as a Computing professional.
PO8. Project Management: Ability to understand management and computing principles
with computing knowledge to manage projects in multidisciplinary environments.
PO9. Communication Efficacy: Communicate effectively with the computing
community as well as society by being able to comprehend effective documentations and
presentations.
PO10. Societal & Environmental Concern: Ability to recognize economical,
environmental, social, health, legal, ethical issues involved in the use of computer
technology and other consequential responsibilities relevant to professional practice.
PO11. Individual & Team Work: Ability to work as a member or leader in diverse
teams in multidisciplinary environment.
PO12. Innovation and Entrepreneurship: Identify opportunities, entrepreneurship
vision and use of innovative ideas to create value and wealth for the betterment of the
individual and society.

4|Page For Internal Circulation


Course Outcomes (COs) :

After completing the course, the students shall be able to

CO1: Understand functioning and working of Operating System


CO2: Explain the concepts of process scheduling, memory and file management
CO3: Understand I/O System
Mapping of Cos with Pos:

1- Low , 2- Medium, 3- High, If no correlation, put ‘-’

Evaluation

Internals: 40%
Externals: 60%
Total : 100%

5|Page For Internal Circulation


Internal Assessment Mapping

Attendance Policy

Rationale for Mapping Program Outcomes and Course Outcomes:

CO1 & PO 2 Helps to understand the basic concepts of


Mapped at 1 Operating System with its types along with
its components.
CO1 & PO 3 Ability to identify the types of Operating
Mapped at 1 System and user types with issues about
users views and system interfaces to be
understood.
6|Page For Internal Circulation
CO1 & PO 5 Ability to select type of Operating System
Mapped at 1 according to IT business and create skills
for selection of type of Operating system.
CO1 & PO7 Create Awareness about recognizing the
Mapped at 1 future needs regarding Operating system
and develop ability to be involved in
continuous thinking among the computing
professionals.
CO1 & PO9 Helps to establish effective channel for
Mapped at 1 communication with computing
community and society with effective
documentations and presentations.
CO1& PO10 Ability for selection of operating system
Mapped at 1 based on economic, environmental, legal
and ethical issues.
CO1 & PO11 Establish ability to work as a single user or
Mapped at 1 administrator in diverse operating system
environments.
CO2 & PO1 Understand and apply conceptual
Mapped at 2 knowledge of process management,
storage management of operating system
for defined problems.
CO2 & PO2 Ability to identify complex concepts of
Mapped at 3 operating system algorithms and deadlock
detection techniques by using
fundamentals of Computer science.
CO2 & PO3 Ability to understand storage management
Mapped at 2 techniques and various algorithms for inter
process communication into proposed
integrated solutions.
CO2 & PO4 Ability to conduct experiments for
Mapped at 2 interpretation of process management and
inter process communication techniques of
operating system.
CO2 & PO5 Ability to make use of modern tools, skills
Mapped at 3 and techniques to illustrate inter process
communication of operating system.
CO2 & PO7 Enhance knowledge to recognize the need
Mapped at 3 for developing in continuous learning for
recent trends about storage management
and its techniques of operating system.
CO2 & PO8 Ability to understand management and
Mapped at 2 operating system principles for enhancing
inter process communications knowledge
to manage projects of different
disciplines.
CO2 & PO10 Knowledge for selection of Storage
7|Page For Internal Circulation
management techniques based on
economic,

Session Plan:

Unit Content Session COs Teaching Cognition Evaluation


(Hrs.) Number Methodology Level Tools
1 Introduction to operating 7 CO1 Lecture with Understand End Term
System Definition and PPTs Internals:
concept of OS, History of OS, Quiz Short
Importance and function of Answers
Operating system. Types of
OS
-Batch System, timesharing,
Multitasking,
Multiprogramming, multi-
processing, online operating
system, real time, distributed
operating system. Views-
command language users
view, system call users view,
structure of OS- simple,
monolithic system and
layered system, client server
model.
User operating - system
interface: command line
interface, GUI, system calls
2 Process Management - 10 CO2 Lecture with Understand End Term
Process concept, Process PPTs & Evaluate Internals:
Control Video Short
Block OS services for Process Answers
management, scheduling and
typesof schedulers,
scheduling
algorithm- First come first
served, shortest job first,
shortest remaining time next,
time slice scheduling,
priority- based scheduling,
multilevel queue, multilevel
queue with
feedback

8|Page For Internal Circulation


3 Storage Management - Basic 10 CO2 Lecture with Understand Assignment
concept of storage PPTs & Evaluate s End Term
management, logical and Video Internals:
physical address space, Short
swapping, contiguous Answers
allocation, non-Contiguous
allocation , fragmentation,
segmentation, paging, demand
paging ,virtual memory, page
replacement algorithms-
FIFO, Optimal page
replacement algorithm, least
recently page replacement
algorithm, clock page
replacement algorithm, design
issue of paging,
thrashing.
4 Inter-process 8 CO2 Lecture with Analyze Classroom
communication and PPTs test End
synchronization - Need, Quiz Term
Mutual Exclusion, Internals:
Semaphore, Busy-wait Short
Answers
Implementation,
characteristics of semaphore,
queuing implementation of
semaphore, producer
consumer problem, critical
region and conditional critical
area. What is deadlock?
Conditions to occur the
deadlock, deadlock
prevention, deadlock
avoidance- banker‘s
algorithm. Resource request,
resource release.
5 File Systems andI/O System 10 CO3 Lecture with Understand Quiz
: File System : Files-basic PPTs & Apply End Term
concept, file attributes, Case Studies Internals:
operations, file types, file Short
structure, accessmethods, Answers
Directory- structure- single
level directory system, two
level directory system,
hierarchical directory system,
directory operations,
protection,security, allocation
method.

9|Page For Internal Circulation


Input/output System:
Principles of I/O hardware,
I/O devices, device controller,
DMA, Principles of I/O
software- goals, interrupt
handler, device driver. Mass
storage structure-disk
structure,
disk scheduling (FCFS, SSTF,
SCAN, LOOK, C- SCAN, C-
LOOK)

10 | P a g e For Internal Circulation


STUDY NOTES

11 | P a g e For Internal Circulation


UNIT 1
Introduction to Operating System:

 Definition and concept of OS


 History of OS
 Importance and function of Operating system.
 Types of OS
 Views-command language users view, system call users view structure of OS
 Command line interface, GUI, system calls

 Operating system
An operating system (OS) is a collection of software that manages computer hardware resources and
provides common services for computer programs. The operating system is a vital component of the system
software in a computer system. This tutorial will take you through step by step approach while learning
Operating System concepts.
An Operating System (OS) is an interface between a computer user and computer hardware. An operating
system is a software which performs all the basic tasks like file management, memory management,
process management, handling input and output, and controlling peripheral devices such as disk drives and
printers.
Some popular Operating Systems include Linux Operating System, Windows Operating System, VMS,
OS/400, AIX, z/OS, etc.
Following are some of important functions of an operating System:

 Memory Management
 Processor Management
 Device Management
 File Management
 Security
 Control over system performance
 Job accounting
 Error detecting aids
 Coordination between other software and users
 Applications of Operating System
Following are some of the important activities that an Operating System performs −
 Security − By means of password and similar other techniques, it prevents unauthorized access to
programs and data.
 Control over system performance − Recording delays between request for a service and response
from the system.
 Job accounting − Keeping track of time and resources used by various jobs and users.
12 | P a g e For Internal Circulation
 Error detecting aids − Production of dumps, traces, error messages, and other debugging and error
detecting aids.
 Coordination between other softwares and users − Coordination and assignment of compilers,
interpreters, assemblers and other software to the various users of the computer systems.
An operating system is a program that acts as an interface between the user and the computer hardware and
controls the execution of all kinds of programs.

For explanation of types of Operating system – refer hand written notes.


Advantages and disadvantages of the types of operating systems

Advantages of Batch Operating System:


 It is very difficult to guess or know the time required by any job to complete. Processors of the batch
systems know how long the job would be when it is in queue
 Multiple users can share the batch systems
 The idle time for batch system is very less
 It is easy to manage large work repeatedly in batch systems

Disadvantages of Batch Operating System:

 The computer operators should be well known with batch systems


 Batch systems are hard to debug
 It is sometime costly
 The other jobs will have to wait for an unknown time if any job fails

13 | P a g e For Internal Circulation


Advantages of Time-Sharing OS:

 Each task gets an equal opportunity


 Less chances of duplication of software
 CPU idle time can be reduced

Disadvantages of Time-Sharing OS:

 Reliability problem
 One must have to take care of security and integrity of user programs and data
 Data communication problem

Distributed Operating System is one of the important type of operating system.


Multiple central processors are used by Distributed systems to serve multiple real-time applications and
multiple users. Accordingly, Data processing jobs are distributed among the processors.
Processors communicate with each other through various communication lines (like high-speed buses or
telephone lines). These are known as loosely coupled systems or distributed systems. Processors in this
system may vary in size and function. They are referred as sites, nodes, computers, and so on.

Advantages of Distributed Operating System:

 Failure of one will not affect the other network communication, as all systems are independent from
each other
 Electronic mail increases the data exchange speed
 Since resources are being shared, computation is highly fast and durable
 Load on host computer reduces
 These systems are easily scalable as many systems can be easily added to the network
 Delay in data processing reduces

Disadvantages of Distributed Operating System:

 Failure of the main network will stop the entire communication


 To establish distributed systems the language which are used are not well defined yet
 These types of systems are not readily available as they are very expensive. Not only that the
underlying software is highly complex and not understood well yet

A network operating system (NOS) is a computer operating system (OS) that is designed primarily to
support workstations, personal computers and, in some instances, older terminals that are connected on a
local area network (LAN). The software behind a NOS allows multiple devices within a network to
communicate and share resources with each other.

14 | P a g e For Internal Circulation


The composition of hardware that typically uses a NOS includes a number of personal computers, a printer,
a server and file server with a local network that connects them together. The role of the NOS is to then
provide basic network services and features that support multiple input requests simultaneously in a
multiuser environment.

Due to earlier versions of basic operating systems not being designed for network use, network operating
systems emerged as a solution for single-user computers.

Network Operating System is one of the important type of operating system.


Network Operating System runs on a server and gives the server the capability to manage data,
users, groups, security, applications, and other networking functions. The basic purpose of the
network operating system is to allow shared file and printer access among multiple computers in a
network, typically a local area network (LAN), a private network or to other networks.
Some examples of network operating systems include Microsoft Windows Server 2003, Microsoft
Windows Server 2008, UNIX, Linux, Mac OS X, Novell NetWare, and BSD.

Advantages of Network Operating System:

 Highly stable centralized servers


 Security concerns are handled through servers
 New technologies and hardware up-gradation are easily integrated to the system
 Server access are possible remotely from different locations and types of systems

Disadvantages of Network Operating System:

 Servers are costly


 User has to depend on central location for most operations
 Maintenance and updates are required regularly

Real-time operating systems (RTOS) are used in environments where a large number of events, mostly
external to the computer system, must be accepted and processed in a short time or within certain
deadlines. such applications are industrial control, telephone switching equipment, flight control, and
real-time simulations. With an RTOS, the processing time is measured in tenths of seconds. This system
is time-bound and has a fixed deadline. The processing in this type of system must occur within the
specified constraints. Otherwise, This will lead to system failure.
Examples of the real-time operating systems: Airline traffic control systems, Command Control Systems,
Airlines reservation system, Heart Peacemaker, Network Multimedia Systems, Robot etc.

15 | P a g e For Internal Circulation


Advantages of RTOS (real time operating system):

 Maximum Consumption: Maximum utilization of devices and system,thus more output from all the
resources
 Task Shifting: Time assigned for shifting tasks in these systems are very less. For example in older
systems it takes about 10 micro seconds in shifting one task to another and in latest systems it takes 3
micro seconds.
 Focus on Application: Focus on running applications and less importance to applications which are in
queue.
 Real time operating system in embedded system: Since size of programs are small, RTOS can also
be used in embedded systems like in transport and others.
 Error Free: These types of systems are error free.
 Memory Allocation: Memory allocation is best managed in these type of systems.

Disadvantages of RTOS:

 Limited Tasks: Very few tasks run at the same time and their concentration is very less on few
applications to avoid errors.
 Use heavy system resources: Sometimes the system resources are not so good and they are expensive
as well.
 Complex Algorithms: The algorithms are very complex and difficult for the designer to write on.
 Device driver and interrupt signals: It needs specific device drivers and interrupt signals to response
earliest to interrupts.
 Thread Priority: It is not good to set thread priority as these systems are very less prone to switching
tasks.

Examples of Real-Time Operating Systems are: Scientific experiments, medical imaging systems,
industrial control systems, weapon systems, robots, air traffic control systems, etc. Types of Operating
Systems

An Operating System performs all the basic tasks like managing files, processes, and memory. Thus
operating system acts as the manager of all the resources, i.e. resource manager. Thus, the operating
system becomes an interface between the user and the machine. It is one of the most required software that
is present in the device.

Operating System is a type of software that works as an interface between the system program and the
hardware. There are several types of Operating Systems many of which are mentioned below. Let’s have a
look at them.

Types of Operating Systems

There are several types of Operating Systems which are mentioned below.

 Batch Operating System


 Multi-Programming System
 Multi-Processing System
 Multi-Tasking Operating System
 Time-Sharing Operating System
16 | P a g e For Internal Circulation
 Distributed Operating System
 Network Operating System
 Real-Time Operating System

1. 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. It is the responsibility of the
operator to sort jobs with similar needs. Batch Operating System is designed to manage and execute a large
number of jobs efficiently by processing them in [Link] Operating System

Examples of Batch Operating Systems: Payroll Systems, Bank Statements, etc.

Advantages of Batch Operating System

 Multiple users can share the batch systems.


 The idle time for the batch system is very less.
 It is easy to manage large work repeatedly in batch systems.

Disadvantages of Batch Operating System

 Batch systems are hard to debug.


 It is sometimes costly.
 The other jobs will have to wait for an unknown time if any job fails.
 In batch operating system the processing time for jobs is commonly difficult to accurately predict
while they are in the queue.
 It is difficult to accurately predict the exact time required for a job to complete while it is in the
queue.

17 | P a g e For Internal Circulation


2. Multi-Programming Operating System

Multiprogramming Operating Systems can be simply illustrated as more than one program is present in the
main memory and any one of them can be kept in execution. This is basically used for better execution of
resources.

MultiProgramming

Advantages of Multi-Programming Operating System

 Multi Programming increases the Throughput of the System.


 It helps in reducing the response time.

Disadvantages of Multi-Programming Operating System

 There is not any facility for user interaction of system resources with the system.

3. Multi-Processing Operating System

Multi-Processing Operating System is a type of Operating System in which more than one CPU is used for
the execution of resources. It betters the throughput of the System.

Multiprocessing Operating System

18 | P a g e For Internal Circulation


Advantages of Multi-Processing Operating System

 It increases the throughput of the system.


 As it has several processors, so, if one processor fails, we can proceed with another processor.

Disadvantages of Multi-Processing Operating System

 Due to the multiple CPU, it can be more complex and somehow difficult to understand.

4. Multi-Tasking Operating System

Multitasking Operating System is simply a multiprogramming Operating System with having facility of a
Round-Robin Scheduling Algorithm. It can run multiple programs simultaneously.

There are two types of Multi-Tasking Systems which are listed below.

Preemptive Multi-Tasking

Cooperative Multi-Tasking

Advantages of Multi-Tasking Operating System

 Multiple Programs can be executed simultaneously in Multi-Tasking Operating System.


 It comes with proper memory management.

Disadvantages of Multi-Tasking Operating System

 The system gets heated in case of heavy programs multiple times.

5. Time-Sharing Operating Systems


19 | P a g e For Internal Circulation
Each task is given some time to execute so that all the tasks work smoothly. Each user gets the time of the
CPU as they use a single system. These systems are also known as Multitasking Systems. The task can be
from a single user or different users also. The time that each task gets to execute is called quantum. After
this time interval is over OS switches over to the next task.

Time-Sharing OS

Advantages of Time-Sharing OS

 Each task gets an equal opportunity.


 Fewer chances of duplication of software.
 CPU idle time can be reduced.
 Resource Sharing: Time-sharing systems allow multiple users to share hardware resources such as
the CPU, memory, and peripherals, reducing the cost of hardware and increasing efficiency.
 Improved Productivity: Time-sharing allows users to work concurrently, thereby reducing the
waiting time for their turn to use the computer. This increased productivity translates to more work
getting done in less time.
 Improved User Experience: Time-sharing provides an interactive environment that allows users to
communicate with the computer in real time, providing a better user experience than batch
processing.

Disadvantages of Time-Sharing OS

 Reliability problem.
 One must have to take care of the security and integrity of user programs and data.
 Data communication problem.

20 | P a g e For Internal Circulation


 High Overhead: Time-sharing systems have a higher overhead than other operating systems due to
the need for scheduling, context switching, and other overheads that come with supporting multiple
users.
 Complexity: Time-sharing systems are complex and require advanced software to manage multiple
users simultaneously. This complexity increases the chance of bugs and errors.
 Security Risks: With multiple users sharing resources, the risk of security breaches increases. Time-
sharing systems require careful management of user access, authentication, and authorization to
ensure the security of data and software.

Examples of Time-Sharing OS with explanation

 IBM VM/CMS: IBM VM/CMS is a time-sharing operating system that was first introduced in
1972. It is still in use today, providing a virtual machine environment that allows multiple users to
run their own instances of operating systems and applications.
 TSO (Time Sharing Option): TSO is a time-sharing operating system that was first introduced in
the 1960s by IBM for the IBM System/360 mainframe computer. It allowed multiple users to access
the same computer simultaneously, running their own applications.
 Windows Terminal Services: Windows Terminal Services is a time-sharing operating system that
allows multiple users to access a Windows server remotely. Users can run their own applications
and access shared resources, such as printers and network storage, in real-time.

6. Distributed Operating System

These types of operating system is a recent advancement in the world of computer technology and are being
widely accepted all over the world and, that too, at a great pace. Various autonomous interconnected
computers communicate with each other using a shared communication network. Independent systems
possess their own memory unit and CPU. These are referred to as loosely coupled systems or distributed
systems. These systems’ processors differ in size and function. The major benefit of working with these
types of the operating system is that it is always possible that one user can access the files or software
which are not actually present on his system but some other system connected within this network i.e.,
remote access is enabled within the devices connected in that network.

21 | P a g e For Internal Circulation


Advantages of Distributed Operating System

 Failure of one will not affect the other network communication, as all systems are independent of
each other.
 Electronic mail increases the data exchange speed.
 Since resources are being shared, computation is highly fast and durable.
 Load on host computer reduces.
 These systems are easily scalable as many systems can be easily added to the network.
 Delay in data processing reduces.

Disadvantages of Distributed Operating System

 Failure of the main network will stop the entire communication.


 To establish distributed systems the language is used not well-defined yet.
 These types of systems are not readily available as they are very expensive. Not only that the
underlying software is highly complex and not understood well yet.

Examples of Distributed Operating Systems are LOCUS, etc.

Issues With Distributed Operating Systems

 Networking causes delays in the transfer of data between nodes of a distributed system. Such delays
may lead to an inconsistent view of data located in different nodes, and make it difficult to know the
chronological order in which events occurred in the system.
 Control functions like scheduling, resource allocation, and deadlock detection have to be performed
in several nodes to achieve computation speedup and provide reliable operation when computers or
networking components fail.
 Messages exchanged by processes present in different nodes may travel over public networks and
pass through computer systems that are not controlled by the distributed operating system. An
intruder may exploit this feature to tamper with messages, or create fake messages to fool the
authentication procedure and masquerade as a user of the system.
22 | P a g e For Internal Circulation
7. Network Operating System

These systems run on a server and provide the capability to manage data, users, groups, security,
applications, and other networking functions. These types of operating systems allow shared access to files,
printers, security, applications, and other networking functions over a small private network. One more
important aspect of Network Operating Systems is that all the users are well aware of the underlying
configuration, of all other users within the network, their individual connections, etc. and that’s why these
computers are popularly known as tightly coupled systems.

Advantages of Network Operating System

 Highly stable centralized servers.


 Security concerns are handled through servers.
 New technologies and hardware up-gradation are easily integrated into the system.
 Server access is possible remotely from different locations and types of systems.

23 | P a g e For Internal Circulation


Disadvantages of Network Operating System

 Servers are costly.


 User has to depend on a central location for most operations.
 Maintenance and updates are required regularly.

Examples of Network Operating Systems are Microsoft Windows Server 2003, Microsoft Windows
Server 2008, UNIX, Linux, Mac OS X, Novell NetWare, BSD, etc.

8. Real-Time Operating System

These types of OSs serve real-time systems. The time interval required to process and respond to inputs is
very small. This time interval is called response time. Real-time systems are used when there are time
requirements that are very strict like missile systems, air traffic control systems, robots, etc.

Types of Real-Time Operating Systems

 Hard Real-Time Systems: Hard Real-Time OSs are meant for applications where time constraints
are very strict and even the shortest possible delay is not acceptable. These systems are built for
saving life like automatic parachutes or airbags which are required to be readily available in case of
an accident. Virtual memory is rarely found in these systems.
 Soft Real-Time Systems: These OSs are for applications where time-constraint is less strict.

24 | P a g e For Internal Circulation


Advantages of RTOS

 Maximum Consumption: Maximum utilization of devices and systems, thus more output from all
the resources.
 Task Shifting: The time assigned for shifting tasks in these systems is very less. For example, in
older systems, it takes about 10 microseconds in shifting from one task to another, and in the latest
systems, it takes 3 microseconds.
 Focus on Application: Focus on running applications and less importance on applications that are
in the queue.
 Real-time operating system in the embedded system: Since the size of programs is small, RTOS
can also be used in embedded systems like in transport and others.
 Error Free: These types of systems are error-free.
 Memory Allocation: Memory allocation is best managed in these types of systems.

Disadvantages of RTOS

 Limited Tasks: Very few tasks run at the same time and their concentration is very less on a few
applications to avoid errors.
 Use heavy system resources: Sometimes the system resources are not so good and they are
expensive as well.
 Complex Algorithms: The algorithms are very complex and difficult for the designer to write on.
 Device driver and interrupt signals: It needs specific device drivers and interrupts signal to
respond earliest to interrupts.
 Thread Priority: It is not good to set thread priority as these systems are very less prone to
switching tasks.

Examples of Real-Time Operating Systems are Scientific experiments, medical imaging systems,
industrial control systems, weapon systems, robots, air traffic control systems, etc

25 | P a g e For Internal Circulation


Operating system – System view and user view

The operating system can be observed from the point of view of the user or the system. This is known as the
user view and the system view respectively. More details about these are given as follows −

User View
The user view depends on the system interface that is used by the users. The different types of user view
experiences can be explained as follows −

 If the user is using a personal computer, the operating system is largely designed to make the
interaction easy. Some attention is also paid to the performance of the system, but there is no need
for the operating system to worry about resource utilization. This is because the personal computer
uses all the resources available and there is no sharing.
 If the user is using a system connected to a mainframe or a minicomputer, the operating system is
largely concerned with resource utilization. This is because there may be multiple terminals
connected to the mainframe and the operating system makes sure that all the resources such as
CPU,memory, I/O devices etc. are divided uniformly between them.
 If the user is sitting on a workstation connected to other workstations through networks, then the
operating system needs to focus on both individual usage of resources and sharing though the
network. This happens because the workstation exclusively uses its own resources but it also needs
to share files etc. with other workstations across the network.
 If the user is using a handheld computer such as a mobile, then the operating system handles the
usability of the device including a few remote operations. The battery level of the device is also
taken into account.
There are some devices that contain very less or no user view because there is no interaction with the users.
Examples are embedded computers in home devices, automobiles etc.
System View
According to the computer system, the operating system is the bridge between applications and hardware. It
is most intimate with the hardware and is used to control it as required.
The different types of system view for operating system can be explained as follows:

 The system views the operating system as a resource allocator. There are many resources such as
CPU time, memory space, file storage space, I/O devices etc. that are required by processes for
execution. It is the duty of the operating system to allocate these resources judiciously to the
processes so that the computer system can run as smoothly as possible.
26 | P a g e For Internal Circulation
 The operating system can also work as a control program. It manages all the processes and I/O
devices so that the computer system works smoothly and there are no errors. It makes sure that the
I/O devices work in a proper manner without creating problems.
 Operating systems can also be viewed as a way to make using hardware easier.
 Computers were required to easily solve user problems. However it is not easy to work directly with
the computer hardware. So, operating systems were developed to easily communicate with the
hardware.
 An operating system can also be considered as a program running at all times in the background of a
computer system (known as the kernel) and handling all the application programs. This is the
definition of the operating system that is generally followed.

History of Operating system

The 1940's - First Generations

The earliest electronic digital computers had no operating systems. Machines of the time were so primitive
that programs were often entered one bit at time on rows of mechanical switches (plug boards).
Programming languages were unknown (not even assembly languages). Operating systems were unheard of
.

The 1950's - Second Generation

By the early 1950's, the routine had improved somewhat with the introduction of punch cards. The General
Motors Research Laboratories implemented the first operating systems in early 1950's for their IBM 701.
The system of the 50's generally ran one job at a time. These were called single-stream batch processing
systems because programs and data were submitted in groups or batches.

The 1960's - Third Generation

The systems of the 1960's were also batch processing systems, but they were able to take better advantage
of the computer's resources by running several jobs at once. So operating systems designers developed the
concept of multiprogramming in which several jobs are in main memory at once; a processor is switched
from job to job as needed to keep several jobs advancing while keeping the peripheral devices in use.

For example, on the system with no multiprogramming, when the current job paused to wait for other I/O
operation to complete, the CPU simply sat idle until the I/O finished. The solution for this problem that
evolved was to partition memory into several pieces, with a different job in each partition. While one job
was waiting for I/O to complete, another job could be using the CPU.

Another major feature in third-generation operating system was the technique called spooling (simultaneous
peripheral operations on line). In spooling, a high-speed device like a disk interposed between a running
program and a low-speed device involved with the program in input/output. Instead of writing directly to a
printer, for example, outputs are written to the disk. Programs can run to completion faster, and other
programs can be initiated sooner when the printer becomes available, the outputs may be printed.

Note that spooling technique is much like thread being spun to a spool so that it may be later be unwound as
needed.
27 | P a g e For Internal Circulation
Another feature present in this generation was time-sharing technique, a variant of multiprogramming
technique, in which each user has an on-line (i.e., directly connected) terminal. Because the user is present
and interacting with the computer, the computer system must respond quickly to user requests, otherwise
user productivity could suffer. Timesharing systems were developed to multiprogram large number of
simultaneous interactive users.

Fourth Generation

With the development of LSI (Large Scale Integration) circuits, chips, operating system entered in the
system entered in the personal computer and the workstation age. Microprocessor technology evolved to the
point that it become possible to build desktop computers as powerful as the mainframes of the 1970s. Two
operating systems have dominated the personal computer scene: MS-DOS, written by Microsoft, Inc. for
the IBM PC and other machines using the Intel 8088 CPU and its successors, and UNIX, which is dominant
on the large personal computers using the Motorola 6899 CPU family.

Early Evolution

 1945: ENIAC, Moore School of Engineering, University of Pennsylvania.


 1949: EDSAC and EDVAC
 1949: BINAC - a successor to the ENIAC
 1951: UNIVAC by Remington
 1952: IBM 701
 1956: The interrupt
 1954-1957: FORTRAN was developed

Operating Systems - Late 1950s


By the late 1950s Operating systems were well improved and started supporting following usages:

 It was able to perform Single stream batch processing.


 It could use Common, standardized, input/output routines for device access.
 Program transition capabilities to reduce the overhead of starting a new job was added.
 Error recovery to clean up after a job terminated abnormally was added.
 Job control languages that allowed users to specify the job definition and resource requirements
were made possible.

Operating Systems - In 1960s

 1961: The dawn of minicomputers


 1962: Compatible Time-Sharing System (CTSS) from MIT

28 | P a g e For Internal Circulation


 1963: Burroughs Master Control Program (MCP) for the B5000 system
 1964: IBM System/360
 1960s: Disks became mainstream
 1966: Minicomputers got cheaper, more powerful, and really useful.
 1967-1968: Mouse was invented.
 1964 and onward: Multics
 1969: The UNIX Time-Sharing System from Bell Telephone Laboratories.

Supported OS Features by 1970s

 Multi User and Multi tasking was introduced.


 Dynamic address translation hardware and Virtual machines came into picture.
 Modular architectures came into existence.
 Personal, interactive systems came into existence.

Accomplishments after 1970

 1971: Intel announces the microprocessor


 1972: IBM comes out with VM: the Virtual Machine Operating System
 1973: UNIX 4th Edition is published
 1973: Ethernet
 1974 The Personal Computer Age begins
 1974: Gates and Allen wrote BASIC for the Altair
 1976: Apple II
 August 12, 1981: IBM introduces the IBM PC
 1983 Microsoft begins work on MS-Windows
 1984 Apple Macintosh comes out
 1990 Microsoft Windows 3.0 comes out
 1991 GNU/Linux
 1992 The first Windows virus comes out
 1993 Windows NT
 2007: iOS
 2008: Android OS

29 | P a g e For Internal Circulation


 Multiprogramming, multitasking, multithreading and multiprocessing
1. Multiprogramming – A computer running more than one program at a time (like running Excel and
Firefox simultaneously).

2. Multiprocessing – A computer using more than one CPU at a time.

3. Multitasking – Tasks sharing a common resource (like 1 CPU).

4. Multithreading is an extension of multitasking.

1. Multi programming –

In a modern computing system, there are usually several concurrent application processes which want to
execute. Now it is the responsibility of the Operating System to manage all the processes effectively and
efficiently.

One of the most important aspects of an Operating System is to multi program.


In a computer system, there are multiple processes waiting to be executed, i.e. they are waiting when the
CPU will be allocated to them and they begin their execution. These processes are also known as jobs. Now
the main memory is too small to accommodate all of these processes or jobs into it. Thus, these processes
are initially kept in an area called job pool. This job pool consists of all those processes awaiting allocation
of main memory and CPU.
CPU selects one job out of all these waiting jobs, brings it from the job pool to main memory and starts
executing it. The processor executes one job until it is interrupted by some external factor or it goes for an
I/O task.

2. Multiprocessing –

In a uni-processor system, only one process executes at a time.


Multiprocessing is the use of two or more CPUs (processors) within a single Computer system. The term
also refers to the ability of a system to support more than one processor within a single computer system.
Now since there are multiple processors available, multiple processes can be executed at a time. These
multi processors share the computer bus, sometimes the clock, memory and peripheral devices also.

3. Multitasking –

As the name itself suggests, multi tasking refers to execution of multiple tasks (say processes, programs,
threads etc.) at a time. In the modern operating systems, we are able to play MP3 music, edit documents in
Microsoft Word, surf the Google Chrome all simultaneously, this is accomplished by means of multi
tasking.
Multitasking is a logical extension of multi programming. The major way in which multitasking differs
from multi programming is that multi programming works solely on the concept of context switching
whereas multitasking is based on time sharing alongside the concept of context switching.

30 | P a g e For Internal Circulation


Context Switching

A context switching is a process that involves switching of the CPU from one process or task to another.
In this phenomenon, the execution of the process that is present in the running state is suspended by the
kernel and another process that is present in the ready state is executed by the CPU.

It is one of the essential features of the multitasking operating system. The processes are switched so
fastly that it gives an illusion to the user that all the processes are being executed at the same time.

But the context switching process involved a number of steps that need to be followed. You can't directly
switch a process from the running state to the ready state. You have to save the context of that process. If
you are not saving the context of any process P then after some time, when the process P comes in the
CPU for execution again, then the process will start executing from starting. But in reality, it should
continue from that point where it left the CPU in its previous execution. So, the context of the process
should be saved before putting any other process in the running state.

A context is the contents of a CPU's registers and program counter at any point in time. Context
switching can happen due to the following reasons:

 When a process of high priority comes in the ready state. In this case, the execution of the running
process should be stopped and the higher priority process should be given the CPU for execution.
 When an interruption occurs then the process in the running state should be stopped and the CPU
should handle the interrupt before doing something else.
 When a transition between the user mode and kernel mode is required then you have to perform
the context switching.

System Calls in OS
In computing, a system call is the programmatic way in which a computer program requests a service from
the kernel of the operating system it is executed on. A system call is a way for programs to interact with
the operating system. A computer program makes a system call when it makes a request to the operating
system’s kernel. System call provides the services of the operating system to the user programs via
Application Program Interface(API). It provides an interface between a process and operating system to
allow user-level processes to request services of the operating system. System calls are the only entry points
into the kernel system. All programs needing resources must use system calls.

31 | P a g e For Internal Circulation


Services Provided by System Calls :
1. Process creation and management
2. Main memory management
3. File Access, Directory and File system management
4. Device handling(I/O)
5. Protection
6. Networking, etc

Types of System Calls : There are 5 different categories of system calls –


1. Process control: end, abort, create, terminate, allocate and free memory.
2. File management: create, open, close, delete, read file etc.
3. Device management
4. Information maintenance
5. Communication

Operating System Structure

A structure of an Operating System determines how it has been designed and how it functions. There are
numerous ways of designing a new structure of an Operating system. In this post, we will learn about six
combinations that have been tested and tried.

TYPES OF OPERATING SYSTEM STRUCTURE

• MONOLYTHIC STRUCTURE
• SIMPLE STRUCTURE
• LAYERED STRUCTURE

Monolithic System structure in an Operating System


In this organizational structure, the entire operating system runs as a single program in the kernel mode. An
operating system is a collection of various procedures linked together in a binary file. In this system, any
procedure can call any other procedure. Since it is running in kernel mode itself, it has all the permissions to
call whatever it wants.
In terms of information hiding, there is none. All procedures are running in kernel mode, so they have
access to all modules and packages of other procedures.
However, using this approach without any restrictions can lead to thousands of procedure calls, and this can
lead to a messy system. For this purpose, the actual OS is constructed in a hierarchy. All the individual
procedures are compiled into a single executable file using the system linker.

32 | P a g e For Internal Circulation


Even a monolithic system has a structure in which it can run in user mode. There already is a basic structure
given by the organization

1. The main procedure that invokes the requested service procedures.


2. A set of service procedures that carry out system calls.
3. A set of utility procedures that help out the system procedures.

Layered Systems Structure in Operating Systems


As the name suggests, this system works in layers.

33 | P a g e For Internal Circulation


There are six layers in the system, each with different purposes.
Layer Function
5 The operator
4 User Programs
3 Input/Output Management
2 Operator-process communication
1 Memory and drum management
0 Processor allocation and multiprogramming

Layer 0 – Processor Allocation and Multiprogramming – This layer deals with the allocation of processor,
switching between the processes when interrupts occur or when the timers expire.
The sequential processes can be programmed individually without having to worry about other processes
running on the processor. That is, layer 0 provides that basic multiprogramming of the CPU
Layer 1 – Memory and Drum Management – This layer deals with allocating memory to the processes in
the main memory. The drum is used to hold parts of the processes (pages) for which space couldn’t be
provided in the main memory. The processes don’t have to worry if there is available memory or not as
layer 1 software takes care of adding pages wherever necessary.
Layer 2 – Operator-Process communication – In this layer, each process communicates with the operator
(user) through the console. Each process has its own operator console and can directly communicate with
the operator.
Layer 3 – Input/Output Management – This layer handles and manages all the I/O devices, and it buffers
the information streams that are made available to it. Each process can communicate directly with the
abstract I/O devices with all of its properties.
Layer 4 – User Programs – The programs used by the user are operated in this layer, and they don’t have to
worry about I/O management, operator/processes communication, memory management, or the processor
allocation.
Layer 5 – The Operator – The system operator process is located in the outer most layer.

Simple Structure
There are many operating systems that have a rather simple structure. These started as small systems and
rapidly expanded much further than their scope. A common example of this is MS-DOS. It was designed
simply for a niche amount for people. There was no indication that it would become so popular.

34 | P a g e For Internal Circulation


 Client-Server Model in Operating Systems
The client-server model in an operating system is a variation of the microkernel system. The middle layer in
the microkernel system is the one with servers. These servers provide some kind of service to clients. This
makes up the client-server model.
Communication between clients and servers is obtained by message passing. To receive a service, one of
the client processes constructs a message saying what it wants and sends it to the appropriate service. The
service then does it work and sends back the answer.
If the clients and servers are on the same machine, then some optimizations are possible. But generally
speaking, they are on different systems and are connected via a network link like LAN or WAN.

35 | P a g e For Internal Circulation


UNIT II
Process Management:

 Process concept
 Process Control Block
 process states and its transitions
 context switch
 OS services for Process management
 scheduling and types of schedulers
 scheduling algorithm

 Introduction of Process Management

Program vs Process
A process is a program in execution. For example, when we write a program in C or C++ and compile it,
the compiler creates binary code. The original code and binary code are both programs. When we actually
run the binary code, it becomes a process.

A single program can create many processes when run multiple times; for example, when we open a .exe or
binary file multiple times, multiple instances begin (multiple processes are created).

Attributes or Characteristics of a Process

A process has following attributes.


1. Process Id: A unique identifier assigned by the operating system
2. Process State: Can be ready, running, etc.
3. CPU registers: Like the Program Counter (CPU registers must be saved and restored when a process is
swapped in and out of CPU)
5. Accounts information:
6. I/O status information: For example, devices allocated to the process, open files, etc
8. CPU scheduling information: For example, Priority (Different processes may have different priorities, for
example a short process may be assigned a low priority in the shortest job first scheduling)

36 | P a g e For Internal Circulation


 Context Switching
The process of saving the context of one process and loading the context of another process is
known as Context Switching. In simple terms, it is like loading and unloading the process from
running state to ready state.
 When does context switching happen?

1. When a high-priority process comes to ready state (i.e. with higher priority than the running process)
2. An Interrupt occurs
3. User and kernel mode switch (It is not necessary though)
4. Preemptive CPU scheduling used.

 Process Control Block


Process Control Block is a data structure that contains information of the process related to it. The process
control block is also known as a task control block, entry of the process table, etc.
Structure of the Process Control Block
The process control stores many data items that are needed for efficient process management. Some of
these data items are explained with the help of the given diagram −

The following are the data items −


Process State
This specifies the process state i.e. new, ready, running, waiting or terminated.
Process Number
This shows the number of the particular process.
Program Counter
This contains the address of the next instruction that needs to be executed in the process.
Registers
37 | P a g e For Internal Circulation
This specifies the registers that are used by the process. They may include accumulators, index registers,
stack pointers, general purpose registers etc.
List of Open Files
These are the different files that are associated with the process
CPU Scheduling Information
The process priority, pointers to scheduling queues etc. is the CPU scheduling information that is contained
in the PCB. This may also include any other scheduling parameters.
Memory Management Information
The memory management information includes the page tables or the segment tables depending on the
memory system used. It also contains the value of the base registers, limit registers etc.
I/O Status Information
This information includes the list of I/O devices used by the process, the list of files etc.
Accounting information
The time limits, account numbers, amount of CPU used, process numbers etc. are all a part of the PCB
accounting information.
Location of the Process Control Block
The process control block is kept in a memory area that is protected from the normal user access. This is
done because it contains important process information. Some of the operating systems place the PCB at the
beginning of the kernel stack for the process as it is a safe location.
 Process State

38 | P a g e For Internal Circulation


New: Newly Created Process (or) being-created process.
Ready: After the creation process moves to the Ready state, i.e. the process is ready for execution.
Running: Currently running process in CPU (only one process at a time can be under execution in a
single processor).
Wait (or Block): When a process requests I/O access.
Complete (or Terminated): The process completed its execution.
Suspended Ready: When the ready queue becomes full, some processes are moved to a suspended
ready state
Suspended Block: When the waiting queue becomes full.

 Process Operations
Process operations in an operating system refer to the various activities the OS performs to manage
processes. These operations include process creation, process scheduling, execution and killing the
process.

 Process Creation
Process creation in an operating system (OS) is the act of generating a new process. This new
process is an instance of a program that can execute independently.
 Scheduling
Once a process is ready to run, it enters the “ready queue.” The scheduler’s job is to pick a
process from this queue and start its execution.
 Execution
Execution means the CPU starts working on the process. During this time, the process might:
 Move to a waiting queue if it needs to perform an I/O operation.
 Get blocked if a higher-priority process needs the CPU.

39 | P a g e For Internal Circulation


 Killing the Process
After the process finishes its tasks, the operating system ends it and removes its Process Control
Block (PCB).

 Preemptive and Non-Preemptive Scheduling


1. Preemptive Scheduling:

Preemptive scheduling is used when a process switches from running state to ready state or from
waiting state to ready state. The resources (mainly CPU cycles) are allocated to the process for the
limited amount of time and then is taken away, and the process is again placed back in the ready queue
if that process still has CPU burst time remaining. That process stays in ready queue till it gets next
chance to execute.

Introduction of Process Management

A process is a program in execution. For example, when we write a program in C or C++ and compile it,
the compiler creates binary code. The original code and binary code are both programs. When we actually
run the binary code, it becomes a process. A process is an ‘active’ entity instead of a program, which is
considered a ‘passive’ entity. A single program can create many processes when run multiple times; for
example, when we open a .exe or binary file multiple times, multiple instances begin (multiple processes
are created).

In this article, we will discuss process management in detail, along with the different states of a process, its
advantages, disadvantages, etc.

What is Process Management?

Process management is a key part of an operating system. It controls how processes are carried out, and
controls how your computer runs by handling the active processes. This includes stopping processes, setting
which processes should get more attention, and many more. You can manage processes on your own
computer too.

The OS is responsible for managing the start, stop, and scheduling of processes, which are programs
running on the system. The operating system uses a number of methods to prevent deadlocks, facilitate
inter-process communication, and synchronize processes. Efficient resource allocation, conflict-free process
execution, and optimal system performance are all guaranteed by competent process management. This
essential component of an operating system enables the execution of numerous applications at once,
enhancing system utilization and responsiveness.

40 | P a g e For Internal Circulation


How Does a Process Look Like in Memory?

A process in memory is divided into several distinct sections, each serving a different purpose. Here’s how
a process typically looks in memory:

 Text Section: A Process, sometimes known as the Text Section, also includes the current activity
represented by the value of the Program Counter.
 Stack: The stack contains temporary data, such as function parameters, returns addresses, and local
variables.
 Data Section: Contains the global variable.
 Heap Section: Dynamically memory allocated to process during its run time.

Characteristics of a Process

A process has the following attributes.

 Process Id: A unique identifier assigned by the operating system.


 Process State: Can be ready, running, etc.
 CPU Registers: Like the Program Counter (CPU registers must be saved and restored when a
process is swapped in and out of the CPU)
 Accounts Information: Amount of CPU used for process execution, time limits, execution ID, etc
 I/O Status Information: For example, devices allocated to the process, open files, etc
 CPU Scheduling Information: For example, Priority (Different processes may have different
priorities, for example, a shorter process assigned high priority in the shortest job first scheduling)

All of the above attributes of a process are also known as the context of the process. Every process has its
own process control block(PCB), i.e. each process will have a unique PCB. All of the above attributes are
part of the PCB.

41 | P a g e For Internal Circulation


Process Creation

Process creation in an operating system (OS) is the act of generating a new process. This new process is an
instance of a program that can execute independently.

Scheduling

Once a process is ready to run, it enters the “ready queue.” The scheduler’s job is to pick a process from
this queue and start its execution.

Execution

Execution means the CPU starts working on the process. During this time, the process might:

 Move to a waiting queue if it needs to perform an I/O operation.


 Get blocked if a higher-priority process needs the CPU.

Killing the Process

After the process finishes its tasks, the operating system ends it and removes its Process Control Block
(PCB).

Context Switching of Process

The process of saving the context of one process and loading the context of another process is known as
Context Switching. In simple terms, it is like loading and unloading the process from the running state to
the ready state.

When Does Context Switching Happen?

Context Switching Happen:

 When a high-priority process comes to a ready state (i.e. with higher priority than the running
process).
 An Interrupt occurs.
 User and kernel-mode switch (It is not necessary though)
 Preemptive CPU scheduling is used.

Context Switch vs Mode Switch

A mode switch occurs when the CPU privilege level is changed, for example when a system call is made or
a fault occurs. The kernel works in more a privileged mode than a standard user task. If a user process
wants to access things that are only accessible to the kernel, a mode switch must occur. The currently
executing process need not be changed during a mode switch. A mode switch typically occurs for a process
context switch to occur. Only the kernel can cause a context switch.

42 | P a g e For Internal Circulation


CPU-Bound vs I/O-Bound Processes

A CPU-bound process requires more CPU time or spends more time in the running state. An I/O-bound
process requires more I/O time and less CPU time. An I/O-bound process spends more time in the waiting
state.

Process planning is an integral part of the process management operating system. It refers to the mechanism
used by the operating system to determine which process to run next. The goal of process scheduling is to
improve overall system performance by maximizing CPU utilization, minimizing execution time, and
improving system response time.

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.

Preemptive Scheduling

CPU-scheduling decisions may take place under the following four circumstances:
1. When a process switches from the running state to the waiting state (for example, as the
result of an I/O request or an invocation of wait for the termination of one of the child
processes)
2. When a process switches from the running state to the ready state (ioi example, when an
interrupt occurs)
3. When a process switches from the waiting state to the ready state (for example, at
completion of I/O)
4. When a process terminates
Dispatcher

 Another component involved in the CPU-scheduling function is the dispatcher.


 The dispatcher is the module that gives control of the CPU to the process selected by the short-term
scheduler.
 This function involves the following:
• Switching context
• Switching to user mode
• Jumping to the proper location in the user program to restart that program
 The 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 known as the
dispatch latency.

CPU Scheduling Criteria


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.
43 | P a g e For Internal Circulation
2. Throughput
A measure of the work done by the CPU is the number of processes being executed and completed per
unit of time. This is called throughput. The throughput may vary depending on the length or duration of
the processes.

3. Turnaround Time
For a particular process, an important criterion 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 the ready queue,
executing in CPU, and waiting for I/O.

Turn Around Time = Completion Time – Arrival Time.

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.

Waiting Time = Turnaround Time – Burst Time.

5. Response Time
In an interactive system, turn-around time is not the best criterion. A process may produce some output
fairly early and continue computing new results while previous results are being output to the user. Thus
another criterion is the time taken from submission of the process of the request until the first response is
produced. This measure is called response time.

Response Time = CPU Allocation Time(when the CPU was allocated for the first) – Arrival Time

44 | P a g e For Internal Circulation


6. Completion Time
The completion time is the time when the process stops executing, which means that the process has
completed its burst time and is completely executed.

7. Priority
If the operating system assigns priorities to processes, the scheduling mechanism should favor the higher-
priority processes.

8. Predictability
A given process always should run in about the same amount of time under a similar system load.

Factors Influencing CPU Scheduling Algorithms


There are many factors that influence the choice of CPU scheduling algorithm. Some of them are listed
below.
 The number of processes.
 The processing time required.
 The urgency of tasks.
 The system requirements.
Selecting the correct algorithm will ensure that the system will use system resources efficiently, increase
productivity, and improve user satisfaction.

Process Scheduling Algorithms

The operating system can use different scheduling algorithms to schedule processes. Here are
some commonly used timing algorithms:

 First-Come, First-Served (FCFS): This is the simplest scheduling algorithm, where the process is
executed on a first-come, first-served basis. FCFS is non-preemptive, which means that once a
process starts executing, it continues until it is finished or waiting for I/O.
 Shortest Job First (SJF): SJF is a proactive scheduling algorithm that selects the process with the
shortest burst time. The burst time is the time a process takes to complete its execution. SJF
minimizes the average waiting time of processes.
 Round Robin (RR): Round Robin is a proactive scheduling algorithm that reserves a fixed amount
of time in a round for each process. If a process does not complete its execution within the specified
time, it is blocked and added to the end of the queue. RR ensures fair distribution of CPU time to all
processes and avoids starvation.
 Priority Scheduling: This scheduling algorithm assigns priority to each process and the process
with the highest priority is executed first. Priority can be set based on process type, importance, or
resource requirements.
 Multilevel Queue: This scheduling algorithm divides the ready queue into several separate
queues, each queue having a different priority. Processes are queued based on their priority, and
each queue uses its own scheduling algorithm. This scheduling algorithm is useful in scenarios
where different types of processes have different priorities.

45 | P a g e For Internal Circulation


Program for FCFS CPU Scheduling

Given n processes with their burst times, the task is to find average waiting time and average turn
around time using FCFS scheduling algorithm.
First in, first out (FIFO), also known as first come, first served (FCFS), is the simplest sched uling
algorithm. FIFO simply queues processes in the order that they arrive in the ready queue.
In this, the process that comes first will be executed first and next process starts only after the
previous gets fully executed.
Here we are considering that arrival time for all processes is 0.

Important Points:

1. Non-preemptive
2. Average Waiting Time is not optimal
3. Cannot utilize resources in parallel: Results in Convoy effect (Consider a situation when many IO
bound processes are there and one CPU bound process. The IO bound processes have to wait for CPU
bound process when CPU bound process acquires CPU. The IO bound process could have better
taken CPU for some time, then used IO devices).

46 | P a g e For Internal Circulation


Program for Shortest Job First (or SJF) CPU Scheduling (Non- preemptive)

The shortest job first (SJF) or shortest job next, is a scheduling policy that selects the waiting process
with the smallest execution time to execute next. SJN, also known as Shortest Job Next (SJN), can
be preemptive or non-preemptive.

Characteristics of SJF Scheduling:


 Shortest Job first has the advantage of having a minimum average waiting time among all scheduling
algorithms.
 It is a Greedy Algorithm.
 It may cause starvation if shorter processes keep coming. This problem can be solved using the
concept of ageing.
 It is practically infeasible as Operating System may not know burst times and therefore may not sort
them. While it is not possible to predict execution time, several methods can be used to estimate the
execution time for a job, such as a weighted average of previous execution times.
 SJF can be used in specialized environments where accurate estimates of running time are available.

Algorithm:
 Sort all the processes according to the arrival time.
 Then select that process that has minimum arrival time and minimum Burst time.
 After completion of the process make a pool of processes that arrives afterward till the completion of
the previous process and select that process among the pool which is having minimum Burst time.

47 | P a g e For Internal Circulation


How to compute below times in SJF using a program?
 Completion Time: Time at which process completes its execution.
 Turn Around Time: Time Difference between completion time and arrival time.
Turn Around Time = Completion Time – Arrival Time
 Waiting Time(W.T): Time Difference between turn around time and burst time.
Waiting Time = Turn Around Time – Burst Time

Program for Non-Preemptive Shortest Job First CPU Scheduling


Non-Preemptive Shortest Job First algorithm can be implemented using Segment Trees data structure.
For detailed implementation of Non-Preemptive Shortest Job First scheduling algorithm, please refer:
Program for Non-Preemptive Shortest Job First CPU Scheduling.
we have assumed arrival times as 0, so turn around and completion times are same.

Examples to show working of Non-Preemptive Shortest Job First CPU Scheduling Algorithm:

Example-1: Consider the following table of arrival time and burst time for five processes P1, P2, P3,
P4 and P5.

Process Burst Time Arrival Time

P1 6 ms 2 ms

P2 2 ms 5 ms

P3 8 ms 1 ms

P4 3 ms 0 ms

P5 4 ms 4 ms

The Shortest Job First CPU Scheduling Algorithm will work on the basis of steps as mentioned below:

At time = 0,
 Process P4 arrives and starts executing

Remaining
Time Arrival Waiting Execution Initial Burst Burst
Instance Process Time Table Time Time Time

0-1ms P4 0ms 1ms 3ms 2ms

At time= 1,
48 | P a g e For Internal Circulation
 Process P3 arrives.
 But, as P4 still needs 2 execution units to complete.
 Thus, P3 will wait till P4 gets executed.
Remaining
Time Arrival Waiting Execution Initial Burst Burst
Instance Process Time Table Time Time Time

P4 0ms 1ms 2ms 1ms


1-2ms
P3 1ms P3 0ms 8ms 8ms

At time =2,
 Process P1 arrives and is added to the waiting table
 P4 will continue its execution.

Remaining
Time Arrival Waiting Execution Initial Burst Burst
Instance Process Time Table Time Time Time

P4 0ms 1ms 1ms 0ms

2-3ms P3 1ms P3 0ms 8ms 8ms

P1 2ms P3, P1 0ms 6ms 6ms

At time = 3,
 Process P4 will finish its execution.
 Then, the burst time of P3 and P1 is compared.
 Process P1 is executed because its burst time is less as compared to P3.

Remaining
Time Arrival Waiting Execution Initial Burst Burst
Instance Process Time Table Time Time Time

P3 1ms P3 0ms 8ms 8ms


3-4ms
P1 2ms P3 1ms 6ms 5ms

At time = 4,
 Process P5 arrives and is added to the waiting Table.
 P1 will continue execution.

Remaining
Time Arrival Waiting Execution Initial Burst Burst
Instance Process Time Table Time Time Time

49 | P a g e For Internal Circulation


Remaining
Time Arrival Waiting Execution Initial Burst Burst
Instance Process Time Table Time Time Time

P3 1ms P3 0ms 8ms 8ms

4-5ms P1 2ms P3 1ms 5ms 4ms

P5 4ms P3, P5 0ms 4ms 4ms

At time = 5,
 Process P2 arrives and is added to the waiting Table.
 P1 will continue execution.

Remaining
Time Arrival Waiting Execution Initial Burst Burst
Instance Process Time Table Time Time Time

P3 1ms P3 0ms 8ms 8ms

P1 2ms P3 1ms 4ms 3ms


5-6ms
P5 4ms P3, P5 0ms 4ms 4ms

P2 5ms P3, P5, P2 0ms 2ms 2ms

At time = 6,
 Process P1 will finish its execution.
 The burst time of P3, P5, and P2 is compared.
 Process P2 is executed because its burst time is the lowest among all.

Remaining
Time Arrival Waiting Execution Initial Burst Burst
Instance Process Time Table Time Time Time

P3 1ms P3 0ms 8ms 8ms

P1 2ms P3 3ms 3ms 0ms


6-9ms
P5 4ms P3, P5 0ms 4ms 4ms

P2 5ms P3, P5, P2 0ms 2ms 2ms

At time=9,
50 | P a g e For Internal Circulation
 Process P2 is executing and P3 and P5 are in the waiting Table.
Remaining
Time Arrival Waiting Execution Initial Burst Burst
Instance Process Time Table Time Time Time

P3 1ms P3 0ms 8ms 8ms

9-11ms P5 4ms P3, P5 0ms 4ms 4ms

P2 5ms P3, P5 2ms 2ms 0ms

At time = 11,
 The execution of Process P2 will be done.
 The burst time of P3 and P5 is compared.
 Process P5 is executed because its burst time is lower than P3.

Remaining
Time Arrival Waiting Execution Initial Burst Burst
Instance Process Time Table Time Time Time

P3 1ms P3 0ms 8ms 8ms


11-15ms
P5 4ms P3 4ms 4ms 0ms

At time = 15,
 Process P5 will finish its execution.

Remaining
Time Arrival Waiting Execution Initial Burst Burst
Instance Process Time Table Time Time Time

15-23ms P3 1ms 8ms 8ms 0ms

At time = 23,
 Process P3 will finish its execution.
 The overall execution of the processes will be as shown below:

Remaining
Time Arrival Waiting Execution Initial Burst Burst
Instance Process Time Table Time Time Time

0-1ms P4 0ms 1ms 3ms 2ms

1-2ms P4 0ms 1ms 2ms 1ms

51 | P a g e For Internal Circulation


Remaining
Time Arrival Waiting Execution Initial Burst Burst
Instance Process Time Table Time Time Time

P3 1ms P3 0ms 8ms 8ms

P4 0ms 1ms 1ms 0ms

2-3ms P3 1ms P3 0ms 8ms 8ms

P1 2ms P3, P1 0ms 6ms 6ms

3-4ms P3 1ms P3 0ms 8ms 8ms

Gantt chart for above execution:

Now, let’s calculate the average waiting time for above example:
P4 = 0 – 0 = 0
P1 = 3 – 2 = 1
P2 = 9 – 5 = 4
P5 = 11 – 4 = 7
P3 = 15 – 1 = 14
Average Waiting Time = 0 + 1 + 4 + 7 + 14/5 = 26/5 = 5.2

Advantages of SJF:
 SJF is better than the First come first serve(FCFS) algorithm as it reduces the average waiting time.
 SJF is generally used for long term scheduling
 It is suitable for the jobs running in batches, where run times are already known.
 SJF is probably optimal in terms of average turnaround time.

Disadvantages of SJF:
 SJF may cause very long turn-around times or starvation.
 In SJF job completion time must be known earlier, but sometimes it is hard to predict.
 Sometimes, it is complicated to predict the length of the upcoming CPU request.
 It leads to the starvation that does not reduce average turnaround time.

52 | P a g e For Internal Circulation


Advantages of Process Management

 Running Multiple Programs: Process management lets you run multiple applications at the same
time, for example, listen to music while browsing the web.
 Process Isolation: It ensures that different programs don’t interfere with each other, so a problem in
one program won’t crash another.
 Fair Resource Use: It makes sure resources like CPU time and memory are shared fairly among
programs, so even lower-priority programs get a chance to run.
 Smooth Switching: It efficiently handles switching between programs, saving and loading their
states quickly to keep the system responsive and minimize delays.

Disadvantages of Process Management

 Overhead: Process management uses system resources because the OS needs to keep track of
various data structures and scheduling queues. This requires CPU time and memory, which can
affect the system’s performance.
 Complexity: Designing and maintaining an OS is complicated due to the need for complex
scheduling algorithms and resource allocation methods.
 Deadlocks: To keep processes running smoothly together, the OS uses mechanisms like semaphores
and mutex locks. However, these can lead to deadlocks, where processes get stuck waiting for each
other indefinitely.
 Increased Context Switching: In multitasking systems, the OS frequently switches between
processes. Storing and loading the state of each process (context switching) takes time and
computing power, which can slow down the system.

Conclusion

In conclusion, process management is a important function of an operating system, ensuring that multiple
programs can run smoothly and efficiently. It involves creating, scheduling, and terminating processes, as
well as managing resources and handling communication between processes. Effective process
management optimizes the use of system resources, maintains system stability, and enhances the overall
performance and responsiveness of the computer. Understanding and implementing robust process
management strategies are crucial for maintaining an efficient and reliable computing environment.

GATE-CS-Questions on Process Management

Q.1: Which of the following need not necessarily be saved on a context switch between processes?
(GATE-CS-2000)

53 | P a g e For Internal Circulation


(A) General purpose registers

(B) Translation lookaside buffer

(C) Program counter

(D) All of the above

Answer: (B)

In a process context switch, the state of the first process must be saved somehow, so that when the
scheduler gets back to the execution of the first process, it can restore this state and continue. The state of
the process includes all the registers that the process may be using, especially the program counter, plus any
other operating system-specific data that may be necessary. A translation look-aside buffer (TLB) is a CPU
cache that memory management hardware uses to improve virtual address translation speed. A TLB has a
fixed number of slots that contain page table entries, which map virtual addresses to physical addresses. On
a context switch, some TLB entries can become invalid, since the virtual-to-physical mapping is different.
The simplest strategy to deal with this is to completely flush the TLB.

Q.2: The time taken to switch between user and kernel modes of execution is t1 while the time taken
to switch between two processes is t2. Which of the following is TRUE? (GATE-CS-2011)

(A) t1 > t2

(B) t1 = t2

(C) t1 < t2

(D) nothing can be said about the relation between t1 and t2.

Answer: (C)

Process switching involves a mode switch. Context switching can occur only in kernel mode.

Frequently Asked Questions on Process Management – FAQs

Why process management is important?

Process management is important in an operating system because it ensures that all the programs running on
your computer work smoothly and efficiently.

What is the main difference between process manager and memory manager?

Processes in the system are manage by processor manager and also it is responsible for the sharing of the
CPU. whereas, memory in the system is managed by memory manager and it is responsible also for
allocation and deallocation of memory, virtual memory management, etc.

What is the difference between a process and a program?


54 | P a g e For Internal Circulation
A program is a set of instructions stored on disk (passive), while a process is an instance of the program in
execution (active). A single program can be associated with multiple processes.

Operations on Processes

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:

55 | P a g e For Internal Circulation


Creation

This is the initial step of the process execution activity. Process creation means the construction of a new
process for execution. This might be performed by the system, the user, or the old process itself. There are
several events that lead to the process creation. Some of the such events are the following:

1. When we start the computer, the system creates several background processes.

2. A user may request to create a new process.

3. A process can create a new process itself while executing.

4. The batch system takes initiation of a batch job.

Scheduling/Dispatching

The event or activity in which the state of the process is changed from ready to run. It means the operating
system puts the process from the ready state into the running state. Dispatching is done by the 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 the running state is preempted and the process in the ready state
is dispatched by the operating system.

Blocking

When a process invokes an input-output system call that blocks the process, and operating system is put in
block mode. Block mode is basically a mode where the process waits for input-output. Hence on the
demand of the process itself, the operating system blocks the process and dispatches another process to the
processor. Hence, in process-blocking operations, the operating system puts the process in a ‘waiting’ state.

Preemption

When a timeout occurs that means the process hadn’t been terminated in the allotted time interval and the
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 a ‘ready’ state.

Process 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 of termination. Some of them are:

1. The process completes its execution fully and it indicates to the OS that it has finished.

2. The operating system itself terminates the process due to service errors.

3. There may be a problem in hardware that terminates the process.


56 | P a g e For Internal Circulation
4. One process can be terminated by another process.

Process Communication (IPC)

A process can be of two types:

 Independent process.
 Co-operating process.

An independent process is not affected by the execution of other processes while a co-operating process can
be affected by other executing processes. Though one can think that those processes, which are running
independently, will execute very efficiently, in reality, there are many situations when co-operative nature
can be utilized for increasing computational speed, convenience, and modularity. Inter-process
communication (IPC) is a mechanism that allows processes to communicate with each other and
synchronize their actions. The communication between these processes can be seen as a method of co-
operation between them. Processes can communicate with each other through both:

1. Shared Memory
2. Message passing

Figure 1 below shows a basic structure of communication between processes via the shared memory
method and via the message passing method.

An operating system can implement both methods of communication. First, we will discuss the shared
memory methods of communication and then message passing. Communication between processes using
shared memory requires processes to share some variable, and it completely depends on how the
programmer will implement it. One way of communication using shared memory can be imagined like this:
Suppose process1 and process2 are executing simultaneously, and they share some resources or use some
information from another process. Process1 generates information about certain computations or resources
being used and keeps it as a record in shared memory. When process2 needs to use the shared information,
it will check in the record stored in shared memory and take note of the information generated by process1
and act accordingly. Processes can use shared memory for extracting information as a record from another
process as well as for delivering any specific information to other processes.
Let’s discuss an example of communication between processes using the shared memory method.

57 | P a g e For Internal Circulation


i) Shared Memory Method

Ex: Producer-Consumer problem


There are two processes: Producer and Consumer. The producer produces some items and the Consumer
consumes that item. The two processes share a common space or memory location known as a buffer where
the item produced by the Producer is stored and from which the Consumer consumes the item if needed.
There are two versions of this problem: the first one is known as the unbounded buffer problem in which
the Producer can keep on producing items and there is no limit on the size of the buffer, the second one is
known as the bounded buffer problem in which the Producer can produce up to a certain number of items
before it starts waiting for Consumer to consume it. We will discuss the bounded buffer problem. First, the
Producer and the Consumer will share some common memory, then the producer will start producing items.
If the total produced item is equal to the size of the buffer, the producer will wait to get it consumed by the
Consumer. Similarly, the consumer will first check for the availability of the item. If no item is available,
the Consumer will wait for the Producer to produce it. If there are items available, Consumer will consume
them. The pseudo-code to demonstrate is provided below:
Shared Data between the two Processes

#define buff_max 25
#define mod %

struct item{

// different member of the produced data


// or consumed data
---------
58 | P a g e For Internal Circulation
}

// An array is needed for holding the items.


// This is the shared place which will be
// access by both process
// item shared_buff [ buff_max ];

// Two variables which will keep track of


// the indexes of the items produced by producer
// and consumer The free index points to
// the next free index. The full index points to
// the first full index.
int free_index = 0;
int full_index = 0;

Producer Process Code

item nextProduced;

while(1){

// check if there is no space


// for production.
// if so keep waiting.
while((free_index+1) mod buff_max == full_index);

shared_buff[free_index] = nextProduced;
free_index = (free_index + 1) mod buff_max;
}

Consumer Process Code

item nextConsumed;

while(1){

// check if there is an available


// item for consumption.
// if not keep on waiting for
59 | P a g e For Internal Circulation
// get them produced.
while((free_index == full_index);

nextConsumed = shared_buff[full_index];
full_index = (full_index + 1) mod buff_max;
}

In the above code, the Producer will start producing again when the (free_index+1) mod buff max will be
free because if it is not free, this implies that there are still items that can be consumed by the Consumer so
there is no need to produce more. Similarly, if free index and full index point to the same index, this implies
that there are no items to consume.

Overall C++ Implementation:


#include <iostream>
#include <mutex>
#include <thread>
#include <vector>

#define buff_max 25
#define mod %

struct item {
// different member of the produced data
// or consumed data
// ---------
};

// An array is needed for holding the items.


// This is the shared place which will be
// access by both process
// item shared_buff[buff_max];

// Two variables which will keep track of


// the indexes of the items produced by producer
// and consumer The free index points to
// the next free index. The full index points to
// the first full index.
std::atomic<int> free_index(0);
std::atomic<int> full_index(0);
std::mutex mtx;

void producer() {
item new_item;
while (true) {
// Produce the item
// ...
60 | P a g e For Internal Circulation
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// Add the item to the buffer
while (((free_index + 1) mod buff_max) == full_index) {
// Buffer is full, wait for consumer
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
[Link]();
// Add the item to the buffer
// shared_buff[free_index] = new_item;
free_index = (free_index + 1) mod buff_max;
[Link]();
}
}

void consumer() {
item consumed_item;
while (true) {
while (free_index == full_index) {
// Buffer is empty, wait for producer
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
[Link]();
// Consume the item from the buffer
// consumed_item = shared_buff[full_index];
full_index = (full_index + 1) mod buff_max;
[Link]();
// Consume the item
// ...
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}

int main() {
// Create producer and consumer threads
std::vector<std::thread> threads;
threads.emplace_back(producer);
threads.emplace_back(consumer);

// Wait for threads to finish


for (auto& thread : threads) {
[Link]();
}

return 0;
}

61 | P a g e For Internal Circulation


Note that the atomic class is used to make sure that the shared variables free_index and full_index are
updated atomically. The mutex is used to protect the critical section where the shared buffer is accessed.
The sleep_for function is used to simulate the production and consumption of items.

ii) Messaging Passing Method

Now, We will start our discussion of the communication between processes via message passing. In this
method, processes communicate with each other without using any kind of shared memory. If two
processes p1 and p2 want to communicate with each other, they proceed as follows:

 Establish a communication link (if a link already exists, no need to establish it again.)
 Start exchanging messages using basic primitives.
We need at least two primitives:

– send(message, destination) or send(message)

– receive(message, host) or receive(message)

The message size can be of fixed size or of variable size. If it is of fixed size, it is easy for an OS designer
but complicated for a programmer and if it is of variable size then it is easy for a programmer but
complicated for the OS designer. A standard message can have two parts: header and body.
The header part is used for storing message type, destination id, source id, message length, and control
information. The control information contains information like what to do if runs out of buffer space,
sequence number, priority. Generally, message is sent using FIFO style.

Message Passing through Communication Link.


62 | P a g e For Internal Circulation
Direct and Indirect Communication link

Now, We will start our discussion about the methods of implementing communication links. While
implementing the link, there are some questions that need to be kept in mind like :

1. How are links established?


2. Can a link be associated with more than two processes?
3. How many links can there be between every pair of communicating processes?
4. What is the capacity of a link? Is the size of a message that the link can accommodate fixed or
variable?
5. Is a link unidirectional or bi-directional?

A link has some capacity that determines the number of messages that can reside in it temporarily for which
every link has a queue associated with it which can be of zero capacity, bounded capacity, or unbounded
capacity. In zero capacity, the sender waits until the receiver informs the sender that it has received the
message. In non-zero capacity cases, a process does not know whether a message has been received or not
after the send operation. For this, the sender must communicate with the receiver explicitly. Implementation
of the link depends on the situation, it can be either a direct communication link or an in-directed
communication link.

Message Passing through Exchanging the Messages.

A process that is blocked is one that is waiting for some event, such as a resource becoming available or the
completion of an I/O operation. IPC is possible between the processes on same computer as well as on the
processes running on different computer i.e. in networked/distributed system. In both cases, the process
may or may not be blocked while sending a message or attempting to receive a message so message passing
may be blocking or non-blocking. Blocking is considered synchronous and blocking send means the
sender will be blocked until the message is received by receiver. Similarly, blocking receive has the
receiver block until a message is available. Non-blocking is considered asynchronous and Non-blocking
send has the sender sends the message and continue. Similarly, Non-blocking receive has the receiver
receive a valid message or null. After a careful analysis, we can come to a conclusion that for a sender it is
more natural to be non-blocking after message passing as there may be a need to send the message to
different processes. However, the sender expects acknowledgment from the receiver in case the send fails.
Similarly, it is more natural for a receiver to be blocking after issuing the receive as the information from
the received message may be used for further execution. At the same time, if the message send keep on
failing, the receiver will have to wait indefinitely. That is why we also consider the other possibility of
message passing. There are basically three preferred combinations:

 Blocking send and blocking receive


 Non-blocking send and Non-blocking receive
 Non-blocking send and Blocking receive (Mostly used)

In Direct message passing, The process which wants to communicate must explicitly name the recipient or
sender of the communication.
63 | P a g e For Internal Circulation
e.g. send(p1, message) means send the message to p1.
Similarly, receive(p2, message) means to receive the message from p2.
In this method of communication, the communication link gets established automatically, which can be
either unidirectional or bidirectional, but one link can be used between one pair of the sender and receiver
and one pair of sender and receiver should not possess more than one pair of links. Symmetry and
asymmetry between sending and receiving can also be implemented i.e. either both processes will name
each other for sending and receiving the messages or only the sender will name the receiver for sending the
message and there is no need for the receiver for naming the sender for receiving the message. The problem
with this method of communication is that if the name of one process changes, this method will not work.
In Indirect message passing, processes use mailboxes (also referred to as ports) for sending and receiving
messages. Each mailbox has a unique id and processes can communicate only if they share a mailbox. Link
established only if processes share a common mailbox and a single link can be associated with many
processes. Each pair of processes can share several communication links and these links may be
unidirectional or bi-directional. Suppose two processes want to communicate through Indirect message
passing, the required operations are: create a mailbox, use this mailbox for sending and receiving messages,
then destroy the mailbox. The standard primitives used are: send(A, message) which means send the
message to mailbox A. The primitive for the receiving the message also works in the same way e.g.
received (A, message). There is a problem with this mailbox implementation. Suppose there are more than
two processes sharing the same mailbox and suppose the process p1 sends a message to the mailbox, which
process will be the receiver? This can be solved by either enforcing that only two processes can share a
single mailbox or enforcing that only one process is allowed to execute the receive at a given time or select
any process randomly and notify the sender about the receiver. A mailbox can be made private to a single
sender/receiver pair and can also be shared between multiple sender/receiver pairs. Port is an
implementation of such mailbox that can have multiple senders and a single receiver. It is used in
client/server applications (in this case the server is the receiver). The port is owned by the receiving process
and created by OS on the request of the receiver process and can be destroyed either on request of the same
receiver processor when the receiver terminates itself. Enforcing that only one process is allowed to execute
the receive can be done using the concept of mutual exclusion. Mutex mailbox is created which is shared
by n process. The sender is non-blocking and sends the message. The first process which executes the
receive will enter in the critical section and all other processes will be blocking and will wait.
Now, let’s discuss the Producer-Consumer problem using the message passing concept. The producer
places items (inside messages) in the mailbox and the consumer can consume an item when at least one
message present in the mailbox. The code is given below:
Producer Code

Inter-process communication (IPC) is the mechanism through which processes or threads can communicate
and exchange data with each other on a computer or across a network. IPC is an important aspect of modern
operating systems, as it enables different processes to work together and share resources, leading to
increased efficiency and flexibility.

Advantages of IPC:

1. Enables processes to communicate with each other and share resources, leading to increased
efficiency and flexibility.
2. Facilitates coordination between multiple processes, leading to better overall system performance.
3. Allows for the creation of distributed systems that can span multiple computers or networks.

64 | P a g e For Internal Circulation


4. Can be used to implement various synchronization and communication protocols, such as
semaphores, pipes, and sockets.

Disadvantages of IPC:

1. Increases system complexity, making it harder to design, implement, and debug.


2. Can introduce security vulnerabilities, as processes may be able to access or modify data belonging
to other processes.
3. Requires careful management of system resources, such as memory and CPU time, to ensure that
IPC operations do not degrade overall system performance.
Can lead to data inconsistencies if multiple processes try to access or modify the same data at the
same time.
4. Overall, the advantages of IPC outweigh the disadvantages, as it is a necessary mechanism for
modern operating systems and enables processes to work together and share resources in a flexible
and efficient manner. However, care must be taken to design and implement IPC systems carefully,
in order to avoid potential security vulnerabilities and performance issues.

Algorithms based on preemptive scheduling are: Round Robin (RR),Shortest Remaining Time First
(SRTF), Priority (preemptive version), etc.

2. Non-Preemptive Scheduling:

Non-preemptive Scheduling is used when a process terminates, or a process switches from running to
waiting state. In this scheduling, once the resources (CPU cycles) is allocated to a process, the process
holds the CPU till it gets terminated or it reaches a waiting state. In case of non-preemptive scheduling
does not interrupt a process running CPU in middle of the execution. Instead, it waits till the process
complete its CPU burst time and then it can allocate the CPU to another process.

Algorithms based on non-preemptive scheduling are: Shortest Job First (SJF basically non
preemptive) and Priority (non preemptive version), etc.

 Note : shortest remaining time next scheduling algorithm( means preemptive version of
shortest job first) for this refer handwritten notes

 Multilevel Queue (MLQ) CPU Scheduling ( also refer handwritten notes)


It may happen that processes in the ready queue can be divided into different classes where each class has
its own scheduling needs. For example, a common division is a foreground (interactive) process
and background (batch) [Link] two classes have different scheduling needs. For this kind of
situation Multilevel Queue Scheduling is [Link], let us see how it works.
65 | P a g e For Internal Circulation
Ready Queue is divided into separate queues for each class of processes. For example, let us take three
different types of process System processes, Interactive processes and Batch Processes. All three process
have there own queue.

All three different type of processes have there own queue. Each queue have its own Scheduling algorithm.
For example, queue 1 and queue 2 uses Round Robin while queue 3 can use FCFS to schedule there
processes.

Scheduling among the queues : What will happen if all the queues have some processes? Which process
should get the cpu? To determine this Scheduling among the queues is necessary. There are two ways to do
so –

1. Fixed priority preemptive scheduling method – Each queue has absolute priority over lower priority
queue. Let us consider following priority order queue 1 > queue 2 > queue [Link] to this
algorithm no process in the batch queue(queue 3) can run unless queue 1 and 2 are empty. If any batch
process (queue 3) is running and any system (queue 1) or Interactive process(queue 2) entered the
ready queue the batch process is preempted.

2. Time slicing – In this method each queue gets certain portion of CPU time and can use it to schedule
its own [Link] instance, queue 1 takes 50 percent of CPU time queue 2 takes 30 p

 Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling Scheduling ( also refer
handwritten notes)
This Scheduling is like Multilevel Queue(MLQ) Scheduling but in this process can move between the
queues. Multilevel Feedback Queue Scheduling (MLFQ) keep analyzing the behavior (time of execution)
66 | P a g e For Internal Circulation
of processes and according to which it changes its priority.

Now let us suppose that queue 1 and 2 follow round robin with time quantum 4 and 8 respectively and
queue 3 follow [Link] implementation of MFQS is given below –

1. When a process starts executing then it first enters queue 1.

2. In queue 1 process executes for 4 unit and if it completes in this 4 unit or it gives CPU for I/O
operation in this 4 unit than the priority of this process does not change and if it again comes in the
ready queue than it again starts its execution in Queue 1.

3. If a process in queue 1 does not complete in 4 unit then its priority gets reduced and it shifted to queue
2.

4. Above points 2 and 3 are also true for queue 2 processes but the time quantum is 8 [Link] a general
case if a process does not complete in a time quantum than it is shifted to the lower priority queue.

5. In the last queue, processes are scheduled in FCFS manner.

6. A process in lower priority queue can only execute only when higher priority queues are empty.

7. A process running in the lower priority queue is interrupted by a process arriving in the higher priority
queue.

Problems in the above implementation – A process in the lower priority queue can suffer from starvation
due to some short processes taking all the CPU time.

Solution – A simple solution can be to boost the priority of all the process after regular intervals and place
them all in the highest priority queue.

Advanatages of using Multilevel feedback queue scheduling

67 | P a g e For Internal Circulation


 Firstly, it is more flexible than the multilevel queue scheduling.

 To optimize turnaround time algorithms like SJF is needed which require the running time of processes
to schedule them. But the running time of the process is not known in advance. MFQS runs a process
for a time quantum and then it can change its priority(if it is a long process). Thus it learns from past
behavior of the process and then predicts its future [Link] way it tries to run shorter process first
thus optimizing turnaround time.

 MFQS also reduces the response time.

68 | P a g e For Internal Circulation


UNIT III
Storage Management:

 Basic concept of storage management


 logical and physical address space
 swapping
 contiguous allocation, non-contiguous allocation, fragmentation
 segmentation
 paging, demand paging, virtual memory
 page replacement algorithms
 design issue of paging and thrashing

Memory management is the functionality of an operating system which handles or manages primary
memory and moves processes back and forth between main memory and disk during execution. Memory
management keeps track of each and every memory location, regardless of either it is allocated to some
process or it is free. It checks how much memory is to be allocated to processes. It decides which process
will get memory at what time. It tracks whenever some memory gets freed or unallocated and
correspondingly it updates the status.

Process Address Space

The process address space is the set of logical addresses that a process references in its code. For example,
when 32-bit addressing is in use, addresses can range from 0 to 0x7fffffff; that is, 2^31 possible numbers,
for a total theoretical size of 2 gigabytes.
The operating system takes care of mapping the logical addresses to physical addresses at the time of
memory allocation to the program. There are three types of addresses used in a program before and after
memory is allocated −

S.N. Memory Addresses & Description

1
Symbolic addresses
The addresses used in a source code. The variable names, constants, and instruction labels are the basic
elements of the symbolic address space.

2
Relative addresses
At the time of compilation, a compiler converts symbolic addresses into relative addresses.

69 | P a g e For Internal Circulation


3
Physical addresses
The loader generates these addresses at the time when a program is loaded into main memory.

Virtual and physical addresses are the same in compile-time and load-time address-binding schemes.
Virtual and physical addresses differ in execution-time address-binding scheme.
The set of all logical addresses generated by a program is referred to as a logical address space. The set of
all physical addresses corresponding to these logical addresses is referred to as a physical address space.
The runtime mapping from virtual to physical address is done by the memory management unit (MMU)
which is a hardware device. MMU uses following mechanism to convert virtual address to physical
address.
 The value in the base register is added to every address generated by a user process, which is treated
as offset at the time it is sent to memory. For example, if the base register value is 10000, then an
attempt by the user to use address location 100 will be dynamically reallocated to location 10100.
 The user program deals with virtual addresses; it never sees the real physical addresses.
 Operating system uses the following memory allocation mechanism.

S.N. Memory Allocation & Description

1
Single-partition allocation
In this type of allocation, relocation-register scheme is used to protect user processes from
each other, and from changing operating-system code and data. Relocation register contains
value of smallest physical address whereas limit register contains range of logical addresses.
Each logical address must be less than the limit register.

2
Multiple-partition allocation
In this type of allocation, main memory is divided into a number of fixed-sized partitions
where each partition should contain only one process. When a partition is free, a process is
selected from the input queue and is loaded into the free partition. When the process
terminates, the partition becomes available for another process.

70 | P a g e For Internal Circulation


Fragmentation

The process of dividing a computer file, such as a data file or an executable program file, into fragments
that are stored in different parts of a computer’s storage medium, such as its hard disc or RAM, is known
as fragmentation in computing.
When a file is fragmented, it is stored on the storage medium in non-contiguous blocks, which means that
the blocks are not stored next to each other. In this article, we are going to discuss fragmentation in detail
along with its type, working, role, advantages, and disadvantages.

 As processes are loaded and removed from memory, the free memory space is broken into little
pieces. It happens after sometimes that processes cannot be allocated to memory blocks considering
their small size and memory blocks remains unused. This problem is known as Fragmentation.
Cause of Fragmentation
This can happen when a file is too large to fit into a single contiguous block of free space on the storage
medium, or when the blocks of free space on the medium are insufficient to hold the file. Because the
system must search for and retrieve individual fragments from different locations in order to open the file,
fragmentation can cause problems when reading or accessing the file.

Effect of Fragmentation
This can reduce system performance and make it more difficult to access the file. It is generally best to
defragment your hard disc on a regular basis to avoid fragmentation, which is a process that rearranges
the blocks of data on the disc so that files are stored in contiguous blocks and can be accessed more
quickly.

Fragmentation is of two types –

1. Internal Fragmentation
Internal fragmentation occurs when there is unused space within a memory block. For example, if a
system allocates a 64KB block of memory to store a file that is only 40KB in size, that block will contain
24KB of internal fragmentation. When the system employs a fixed-size block allocation method, such as
a memory allocator with a fixed block size, this can occur.

71 | P a g e For Internal Circulation


2. External Fragmentation
External fragmentation occurs when a storage medium, such as a hard disc or solid-state drive, has many
small blocks of free space scattered throughout it. This can happen when a system creates and deletes
files frequently, leaving many small blocks of free space on the medium. When a system needs to store a
new file, it may be unable to find a single contiguous block of free space large enough to store the file
and must instead store the file in multiple smaller blocks. This can cause external fragmentation and
performance problems when accessing the file.

S.N. Fragmentation & Description

1
External fragmentation
Total memory space is enough to satisfy a request or to reside a process in it, but it is not
contiguous, so it cannot be used.

2
Internal fragmentation
Memory block assigned to process is bigger. Some portion of memory is left unused, as it
cannot be used by another process.

72 | P a g e For Internal Circulation


Paging
A computer can address more memory than the amount physically installed on the system. This extra
memory is actually called virtual memory and it is a section of a hard that's set up to emulate the
computer's RAM. Paging technique plays an important role in implementing virtual memory.
Paging is a memory management technique in which process address space is broken into blocks of the
same size called pages (size is power of 2, between 512 bytes and 8192 bytes). The size of the process is
measured in the number of pages.
Similarly, main memory is divided into small fixed-sized blocks of (physical) memory called frames and
the size of a frame is kept the same as that of a page to have optimum utilization of the main memory and
to avoid external fragmentation.

Address Translation
Page address is called logical address and represented by page number and the offset.
Logical Address = Page number + page offset
Frame address is called physical address and represented by a frame number and the offset.
Physical Address = Frame number + page offset
A data structure called page map table is used to keep track of the relation between a page of a process to
a frame in physical memory.

73 | P a g e For Internal Circulation


When the system allocates a frame to any page, it translates this logical address into a physical address and
create entry into the page table to be used throughout execution of the program.
When a process is to be executed, its corresponding pages are loaded into any available memory frames.
Suppose you have a program of 8Kb but your memory can accommodate only 5Kb at a given point in
time, then the paging concept will come into picture. When a computer runs out of RAM, the operating
system (OS) will move idle or unwanted pages of memory to secondary memory to free up RAM for other
processes and brings them back when needed by the program.
This process continues during the whole execution of the program where the OS keeps removing idle
pages from the main memory and write them onto the secondary memory and bring them back when
required by the program.
Advantages and Disadvantages of Paging
Here is a list of advantages and disadvantages of paging −
 Paging reduces external fragmentation, but still suffer from internal fragmentation.
 Paging is simple to implement and assumed as an efficient memory management technique.
 Due to equal size of the pages and frames, swapping becomes very easy.
 Page table requires extra memory space, so may not be good for a system having small RAM.

74 | P a g e For Internal Circulation


Segmentation
Segmentation is a memory management technique in which each job is divided into several segments of
different sizes, one for each module that contains pieces that perform related functions. Each segment is
actually a different logical address space of the program.
When a process is to be executed, its corresponding segmentation are loaded into non-contiguous memory
though every segment is loaded into a contiguous block of available memory.
Segmentation memory management works very similar to paging but here segments are of variable-length
where as in paging pages are of fixed size.
A program segment contains the program's main function, utility functions, data structures, and so on. The
operating system maintains a segment map table for every process and a list of free memory blocks along
with segment numbers, their size and corresponding memory locations in main memory. For each
segment, the table stores the starting address of the segment and the length of the segment. A reference to a
memory location includes a value that identifies a segment and an offset.

A Process Scheduler schedules different processes to be assigned to the CPU based on particular
scheduling algorithms. There are six popular process scheduling algorithms which we are going to discuss
in this chapter −

 First-Come, First-Served (FCFS) Scheduling


 Shortest-Job-Next (SJN) Scheduling
75 | P a g e For Internal Circulation
 Priority Scheduling
 Shortest Remaining Time
 Round Robin(RR) Scheduling
 Multiple-Level Queues Scheduling
These algorithms are either non-preemptive or preemptive. Non-preemptive algorithms are designed so
that once a process enters the running state, it cannot be preempted until it completes its allotted time,
whereas the preemptive scheduling is based on priority where a scheduler may preempt a low priority
running process anytime when a high priority process enters into a ready state.
First Come First Serve (FCFS)

 Jobs are executed on first come, first serve basis.


 It is a non-preemptive, pre-emptive scheduling algorithm.
 Easy to understand and implement.
 Its implementation is based on FIFO queue.
 Poor in performance as average wait time is high.

Wait time of each process is as follows −

Process Wait Time : Service Time - Arrival Time

P0 0-0=0

P1 5-1=4

P2 8-2=6

76 | P a g e For Internal Circulation


P3 16 - 3 = 13

Average Wait Time: (0+4+6+13) / 4 = 5.75


Shortest Job Next (SJN)
 This is also known as shortest job first, or SJF
 This is a non-preemptive, pre-emptive scheduling algorithm.
 Best approach to minimize waiting time.
 Easy to implement in Batch systems where required CPU time is known in advance.
 Impossible to implement in interactive systems where required CPU time is not known.
 The processer should know in advance how much time process will take.
Given: Table of processes, and their Arrival time, Execution time

Process Arrival Time Execution Time Service Time

P0 0 5 0

P1 1 3 5

P2 2 8 14

P3 3 6 8

Waiting time of each process is as follows −

Process Waiting Time

P0 0-0=0

P1 5-1=4

P2 14 - 2 = 12

77 | P a g e For Internal Circulation


P3 8-3=5

Average Wait Time: (0 + 4 + 12 + 5)/4 = 21 / 4 = 5.25


Priority Based Scheduling
 Priority scheduling is a non-preemptive algorithm and one of the most common scheduling
algorithms in batch systems.
 Each process is assigned a priority. Process with highest priority is to be executed first and so on.
 Processes with same priority are executed on first come first served basis.
 Priority can be decided based on memory requirements, time requirements or any other resource
requirement.
Given: Table of processes, and their Arrival time, Execution time, and priority. Here we are considering 1
is the lowest priority.

Process Arrival Time Execution Time Priority Service Time

P0 0 5 1 0

P1 1 3 2 11

P2 2 8 1 14

P3 3 6 3 5

Waiting time of each process is as follows −

Process Waiting Time

P0 0-0=0

P1 11 - 1 = 10

P2 14 - 2 = 12

78 | P a g e For Internal Circulation


P3 5-3=2

Average Wait Time: (0 + 10 + 12 + 2)/4 = 24 / 4 = 6


Shortest Remaining Time
 Shortest remaining time (SRT) is the preemptive version of the SJN algorithm.
 The processor is allocated to the job closest to completion but it can be preempted by a newer ready
job with shorter time to completion.
 Impossible to implement in interactive systems where required CPU time is not known.
 It is often used in batch environments where short jobs need to give preference.
Round Robin Scheduling
 Round Robin is the preemptive process scheduling algorithm.
 Each process is provided a fix time to execute, it is called a quantum.
 Once a process is executed for a given time period, it is preempted and other process executes for a
given time period.
 Context switching is used to save states of preempted processes.

Wait time of each process is as follows −

Process Wait Time : Service Time - Arrival Time

P0 (0 - 0) + (12 - 3) = 9

P1 (3 - 1) = 2

P2 (6 - 2) + (14 - 9) + (20 - 17) = 12

79 | P a g e For Internal Circulation


P3 (9 - 3) + (17 - 12) = 11

Average Wait Time: (9+2+12+11) / 4 = 8.5


Multiple-Level Queues Scheduling
Multiple-level queues are not an independent scheduling algorithm. They make use of other existing
algorithms to group and schedule jobs with common characteristics.

 Multiple queues are maintained for processes with common characteristics.


 Each queue can have its own scheduling algorithms.
 Priorities are assigned to each queue.
For example, CPU-bound jobs can be scheduled in one queue and all I/O-bound jobs in another queue. The
Process Scheduler then alternately selects jobs from each queue and assigns them to the CPU based on the
algorithm assigned to the queue.

80 | P a g e For Internal Circulation


UNIT IV

Inter-process communication and synchronization

 Mutual Exclusion
 Semaphore
 Busy-wait Implementation
 characteristics of semaphore
 queuing implementation of semaphore
 producer consumer problem
 Critical region and conditional critical area.
 Deadlock

What is Mutual Exclusion in Synchronization?

A key component of synchronizing simultaneous tasks is mutual exclusion, which enables various threads
to make use of resources that are shared with no tampering with one another's operation. Race conditions, in
which various threads attempt to gain access to and change shared information simultaneously, can be
prevented by implementing mutual exclusion.

Techniques of Mutual Exclusion in Synchronization

Mutual exclusion can be achieved using a variety of strategies, such as the following−

 Locks/Mutexes − To safeguard resources that are shared, synchronization primitives called locks or
mutexes (short for mutual exclusion) are implemented. There are two possible states for a lock:
locked and unlocked. An operating system or procedure must obtain the lock before being able to
utilize the resource that is shared. The requesting string is going to be restricted as long as the lock
has been released if it has already been locked by a distinct thread.
 Semaphores − Another synchronization tool utilized for mutual exclusion is the semaphore. They
could be thought of as an all-purpose lock. When a thread needs to enter the critical area,
semaphores keep track of a counter and decrease it. The running thread becomes immobilized if the
counter decreases, signifying that the critical portion has become in use.
 Atomic Operations − Without using locks or semaphores, certain processors offer atomic
operations which may be employed to guarantee mutual exclusion. Atomic operations are
advantageous for modifying shared parameters because they are unbreakable and can't be stopped. A
property of a variable may only be altered using atomic compare-and-swap (CAS) procedures, for
instance, if the value of the variable coincides with the value that is anticipated.
 Software-based Techniques − Mutual exclusion can be achieved using a variety of software-based
algorithms and strategies, including Peterson's algorithm, Dekker's algorithm, or Lamport's bakery
81 | P a g e For Internal Circulation
algorithm. These techniques make a guarantee that only a single thread at one point is able to utilize
the critical component by combining factors, flags, and busy-waiting.

Use cases of Mutual Exclusion in Synchronization

Below are a few instances of mutual exclusion in synchronization that happened in real-time −

 Printer Spooling − Several procedures or individuals may ask for printed documents at once in an
OS with a number of users. Mutual exclusion is used to guarantee that just one process at the
moment has access to the printer. In order to provide restricted access to the printer, avoid conflicts,
and guarantee that printed positions are dealt with in the proper order, a lock or semaphore is used.
 Bank Account Transactions − Many people may simultaneously try to obtain and alter their
financial accounts in an electronic banking system. In order to avoid problems like overloading or
erratic accounts, mutual exclusion is required. A single transaction is allowed to access a certain
bank account at a time using locks or other synchronization primitives, maintaining the
confidentiality of the information and avoiding conflicts.
 Traffic Signal Control − Traffic signals at a crosswalk must be coordinated in order to safely
manage the movement of transport vehicles. In order to avoid competing communication from being
displayed at once, mutual exclusion is used. One indicator is allowed to be present at a time thanks
to the mutual exclusion rule, which promotes efficient and organized traffic flow.
 Resource Allocation in Shared Database − Mutual exclusion is essential to preserving information
consistency in database systems where various procedures or transactions access information that is
shared concurrently. For instance, mutual exclusion mechanisms make absolutely certain that just a
single transaction is able to alter identical data at a time, hindering disagreements and maintaining
data integrity when two separate operations try to alter the same information concurrently.
 Accessing Shared Memory in Real-Time Systems − Mutual exclusion is required in real-time
systems in which operations or procedures require shared memory to facilitate interaction or
cooperation. Important memory-sharing regions are protected using synchronization basic functions
like locks or semaphores, which make sure that only a single assignment is able to use and alter the
area of shared memory at once.

82 | P a g e For Internal Circulation


Semaphores in Process Synchronization

Semaphores are just normal variables used to coordinate the activities of multiple processes in a computer
system. They are used to enforce mutual exclusion, avoid race conditions, and implement synchronization
between processes.
The process of using Semaphores provides two operations: wait (P) and signal (V). The wait operation
decrements the value of the semaphore, and the signal operation increments the value of the semaphore.
When the value of the semaphore is zero, any process that performs a wait operation will be blocked until
another process performs a signal operation.
Semaphores are used to implement critical sections, which are regions of code that must be executed by
only one process at a time. By using semaphores, processes can coordinate access to shared resources,
such as shared memory or I/O devices.
A semaphore is a special kind of synchronization data that can be used only through specific
synchronization primitives. When a process performs a wait operation on a semaphore, the
operation checks whether the value of the semaphore is >0. If so, it decrements the value of
the semaphore and lets the process continue its execution; otherwise, it blocks the process on
the semaphore. A signal operation on a semaphore activates a process blocked on the
semaphore if any, or increments the value of the semaphore by 1. Due to these semantics,
semaphores are also called counting semaphores. The initial value of a semaphore
determines how many processes can get past the wait operation.
Semaphores are of two types:
1. Binary Semaphore –
This is also known as a mutex lock. It can have only two values – 0 and 1. Its value is initialized to 1.
It is used to implement the solution of critical section problems with multiple processes.
2. Counting Semaphore –
Its value can range over an unrestricted domain. It is used to control access to a resource that has
multiple instances.
3. Now let us see how it does so.
4. First, look at two operations that can be used to access and change the value of the semaphore
variable.

Some points regarding P and V operation:


1. P operation is also called wait, sleep, or down operation, and V operation is also called signal, wake-
up, or up operation.
83 | P a g e For Internal Circulation
2. Both operations are atomic and semaphore(s) is always initialized to one. Here atomic means that
variable on which read, modify and update happens at the same time/moment with no pre-emption i.e.
in-between read, modify and update no other operation is performed that may change the variable.
3. A critical section is surrounded by both operations to implement process synchronization. See the
below image. The critical section of Process P is in between P and V operation.

Now, let us see how it implements mutual exclusion. Let there be two processes P1 and P2 and a
semaphore s is initialized as 1. Now if suppose P1 enters in its critical section then the value of
semaphore s becomes 0. Now if P2 wants to enter its critical section then it will wait until s > 0, this can
only happen when P1 finishes its critical section and calls V operation on semaphore s.
This way mutual exclusion is achieved. Look at the below image for details which is a Binary semaphore

Limitations :
1. One of the biggest limitations of semaphore is priority inversion.
2. Deadlock, suppose a process is trying to wake up another process that is not in a sleep state.
Therefore, a deadlock may block indefinitely.
84 | P a g e For Internal Circulation
3. The operating system has to keep track of all calls to wait and signal the semaphore.
Problem in this implementation of a semaphore:
The main problem with semaphores is that they require busy waiting, If a process is in the critical section,
then other processes trying to enter the critical section will be waiting until the critical section is not
occupied by any process. Whenever any process waits then it continuously checks for semaphore value
(look at this line while (s==0); in P operation) and waste CPU cycle.
There is also a chance of “spinlock” as the processes keep on spins while waiting for the lock. In order to
avoid this another implementation is provided below.
Advantages of Semaphores:
 A simple and effective mechanism for process synchronization
 Supports coordination between multiple processes
 Provides a flexible and robust way to manage shared resources.
 It can be used to implement critical sections in a program.
 It can be used to avoid race conditions.
Disadvantages of Semaphores:
 It Can lead to performance degradation due to overhead associated with wait and signal operations.
 Can result in deadlock if used incorrectly.
 It was proposed by Dijkstra in 1965 which is a very significant technique to manage concurrent
processes by using a simple integer value, which is known as a semaphore. A semaphore is simply an
integer variable that is shared between threads. This variable is used to solve the critical section
problem and to achieve process synchronization in the multiprocessing environment.
 It can cause performance issues in a program if not used properly.
 It can be difficult to debug and maintain.
 It can be prone to race conditions and other synchronization problems if not used correctly.
 It can be vulnerable to certain types of attacks, such as denial of service attacks.

Producer Consumer Problem using Semaphores


The Producer-Consumer problem is a classic synchronization issue in operating systems. It involves
two types of processes: producers, which generate data, and consumers, which process that data. Both
share a common buffer. The challenge is to ensure that the producer doesn’t add data to a full buffer
and the consumer doesn’t remove data from an empty buffer while avoiding conflicts when accessing
the buffer. In this article, we are going to solve this problem by using semaphores.

Producer Consumer Problem Statement


We have a buffer of fixed size. A producer can produce an item and can place it in the buffer. A
consumer can pick items and consume them. We need to ensure that when a producer is placing an item
in the buffer, then at the same time consumer should not consume any item. In this problem, the buffer is
the critical section.
To solve this problem, we need two counting semaphores – Full and Empty. “Full” keeps track of some
items in the buffer at any given time and “Empty” keeps track of many unoccupied slots.

Initialization of semaphores
mutex = 1
Full = 0 // Initially, all slots are empty. Thus full slots are 0
Empty = n // All slots are empty initially

85 | P a g e For Internal Circulation


Solution for Producer
do{

//produce an item

wait(empty);
wait(mutex);

//place in buffer

signal(mutex);
signal(full);

}while(true)

When producer produces an item then the value of “empty” is reduced by 1 because one slot will be filled
now. The value of mutex is also reduced to prevent consumer to access the buffer. Now, the producer has
placed the item and thus the value of “full” is increased by 1. The value of mutex is also increased by 1
because the task of producer has been completed and consumer can access the buffer.

Solution for Consumer


do{

wait(full);
wait(mutex);

// consume item from buffer

signal(mutex);
signal(empty);

}while(true)
As the consumer is removing an item from buffer, therefore the value of “full” is reduced by 1 and the
value is mutex is also reduced so that the producer cannot access the buffer at this moment. Now, the
consumer has consumed the item, thus increasing the value of “empty” by 1. The value of mutex is also
increased so that producer can access the buffer now.

86 | P a g e For Internal Circulation


Producer Consumer Problem using Semaphores – FAQs

How do semaphores solve the Producer-Consumer problem?


Semaphores help manage access to the shared buffer by signaling when the producer can add data (when
there is space) and when the consumer can remove data (when there is data available).

What happens if the buffer is full?


If the buffer is full, the producer waits (blocks) until there is space available, as indicated by the empty
semaphore.

What happens if the buffer is empty


If the buffer is empty, the consumer waits (blocks) until there is data available, as indicated by the full
semaphore.

Are there other methods to solve the Producer-Consumer problem?


Yes, besides semaphores, other methods like monitors and message passing can also be used to solve the
Producer-Consumer problem.

Readers-Writers Problem

The readers-writer problem in operating systems is about managing access to shared data. It allows
multiple readers to read data at the same time without issues but ensures that only one writer can write at
a time, and no one can read while writing is happening. This helps prevent data corruption and ensures
smooth operation in multi-user systems.

What is The Readers-Writers Problem?

The Readers-Writers Problem is a classic synchronization issue in operating systems that involves
managing access to shared data by multiple threads or processes. The problem addresses the scenario
where:
 Readers: Multiple readers can access the shared data simultaneously without causing any issues
because they are only reading and not modifying the data.
 Writers: Only one writer can access the shared data at a time to ensure data integrity, as writers
modify the data, and concurrent modifications could lead to data corruption or inconsistencies.

Problem Parameters
 One set of data is shared among a number of processes
 Once a writer is ready, it performs its write. Only one writer may write at a time
 If a process is writing, no other process can read it
 If at least one reader is reading, no other process can write
 Readers may not write and only read

87 | P a g e For Internal Circulation


Solution When Reader Has The Priority Over Writer

Here priority means, no reader should wait if the share is currently open for reading. There are four types
of cases that could happen here.

Case Process 1 Process 2 Allowed/Not Allowed

Case 1 Writing Writing Not Allowed

Case 2 Writing Reading Not Allowed

Case 3 Reading Writing Not Allowed

Case 4 Reading Reading Allowed

Three variables are used: mutex, wrt, readcnt to implement a solution.


1. semaphore mutex, wrt; // semaphore mutex is used to ensure mutual exclusion when readcnt is
updated i.e. when any reader enters or exits from the critical section, and semaphore wrt is used by
both readers and writers
2. int readcnt; //readcnt tells the number of processes performing read in the critical section, initially 0

Functions for Semaphore

Semaphores are synchronization tools used in operating systems to manage access to shared resources by
multiple threads or processes. They use simple integer values and two main operations to control access:
 wait() : decrements the semaphore value.
 signal() : increments the semaphore value.

Writer Process
 Writer requests the entry to critical section.
 If allowed i.e. wait() gives a true value, it enters and performs the write. If not allowed, it keeps on
waiting.
 It exits the critical section.

do {
// writer requests for critical section
wait(wrt);

// performs the write

// leaves the critical section


88 | P a g e For Internal Circulation
signal(wrt);

} while(true);

Reader Process

 Reader requests the entry to critical section.


 If allowed:
o it increments the count of number of readers inside the critical section. If this reader is the
first reader entering, it locks the wrt semaphore to restrict the entry of writers if any reader
is inside.
o It then, signals mutex as any other reader is allowed to enter while others are already
reading.

o After performing reading, it exits the critical section. When exiting, it checks if no more
reader is inside, it signals the semaphore “wrt” as now, writer can enter the critical section.
 If not allowed, it keeps on waiting.

Dining Philosopher Problem Using Semaphores

The Dining Philosopher Problem states that K philosophers are seated around a circular table with one
chopstick between each pair of philosophers. There is one chopstick between each philosopher. A
philosopher may eat if he can pick up the two chopsticks adjacent to him. One chopstick may be
picked up by any one of its adjacent followers but not both.

89 | P a g e For Internal Circulation


Semaphore Solution to Dining Philosopher

Each philosopher is represented by the following pseudocode:

process P[i]
while true do
{ THINK;
PICKUP(CHOPSTICK[i], CHOPSTICK[i+1 mod 5]);
EAT;
PUTDOWN(CHOPSTICK[i], CHOPSTICK[i+1 mod 5])
}

There are three states of the philosopher: THINKING, HUNGRY, and EATING. Here there are two
semaphores: Mutex and a semaphore array for the philosophers. Mutex is used such that no two
philosophers may access the pickup or put it down at the same time. The array is used to control the
behavior of each philosopher. But, semaphores can result in deadlock due to programming errors.
The Dining Philosopher Problem is a classic synchronization problem in computer science that involves
multiple processes (philosophers) sharing a limited set of resources (forks) in order to perform a task
(eating). In order to avoid deadlock or starvation, a solution must be implemented that ensures that each
philosopher can access the resources they need to perform their task without interference from other
philosophers.
One common solution to the Dining Philosopher Problem uses semaphores, a synchronization mechanism
that can be used to control access to shared resources. In this solution, each fork is represented by a
semaphore, and a philosopher must acquire both the semaphore for the fork to their left and the
semaphore for the fork to their right before they can begin eating. If a philosopher cannot acquire both
semaphores, they must wait until they become available.

The steps for the Dining Philosopher Problem solution using semaphores are as follows
1. Initialize the semaphores for each fork to 1 (indicating that they are available).
2. Initialize a binary semaphore (mutex) to 1 to ensure that only one philosopher can attempt to pick up a
fork at a time.
3. For each philosopher process, create a separate thread that executes the following code:
 While true:
o Think for a random amount of time.
o Acquire the mutex semaphore to ensure that only one philosopher can attempt to pick up a
fork at a time.
o Attempt to acquire the semaphore for the fork to the left.
 If successful, attempt to acquire the semaphore for the fork to the right.
 If both forks are acquired successfully, eat for a random amount of time and then release both
semaphores.
 If not successful in acquiring both forks, release the semaphore for the fork to the left (if acquired)
and then release the mutex semaphore and go back to thinking.
4. Run the philosopher threads concurrently.
By using semaphores to control access to the forks, the Dining Philosopher Problem can be solved in a
way that avoids deadlock and starvation. The use of the mutex semaphore ensures that only one
philosopher can attempt to pick up a fork at a time, while the use of the fork semaphores ensures that a
philosopher can only eat if both forks are available.

90 | P a g e For Internal Circulation


Overall, the Dining Philosopher Problem solution using semaphores is a classic example of how
synchronization mechanisms can be used to solve complex synchronization problems in concurrent
programming.

Deadlock
A deadlock happens in operating system when two or more processes need some resource to complete their
execution that is held by the other process.

In the above diagram, the process 1 has resource 1 and needs to acquire resource 2. Similarly process 2 has
resource 2 and needs to acquire resource 1. Process 1 and process 2 are in deadlock as each of them needs
the other’s resource to complete their execution but neither of them is willing to relinquish their resources.
Coffman Conditions
A deadlock occurs if the four Coffman conditions hold true. But these conditions are not mutually
exclusive.
The Coffman conditions are given as follows −

 Mutual Exclusion
There should be a resource that can only be held by one process at a time. In the diagram below,
there is a single instance of Resource 1 and it is held by Process 1 only.

91 | P a g e For Internal Circulation


 Hold and Wait
A process can hold multiple resources and still request more resources from other processes which
are holding them. In the diagram given below, Process 2 holds Resource 2 and Resource 3 and is
requesting the Resource 1 which is held by Process 1.

 No Preemption
A resource cannot be preempted from a process by force. A process can only release a resource
voluntarily. In the diagram below, Process 2 cannot preempt Resource 1 from Process 1. It will only
be released when Process 1 relinquishes it voluntarily after its execution is complete.

 Circular Wait
A process is waiting for the resource held by the second process, which is waiting for the resource
held by the third process and so on, till the last process is waiting for a resource held by the first
process. This forms a circular chain. For example: Process 1 is allocated Resource2 and it is
requesting Resource 1. Similarly, Process 2 is allocated Resource 1 and it is requesting Resource 2.
This forms a circular wait loop.

92 | P a g e For Internal Circulation


Deadlock Detection
A deadlock can be detected by a resource scheduler as it keeps track of all the resources that are allocated to
different processes. After a deadlock is detected, it can be resolved using the following methods −

 All the processes that are involved in the deadlock are terminated. This is not a good approach as all
the progress made by the processes is destroyed.
 Resources can be preempted from some processes and given to others till the deadlock is resolved.
Deadlock Prevention
It is very important to prevent a deadlock before it can occur. So, the system checks each transaction before
it is executed to make sure it does not lead to deadlock. If there is even a slight chance that a transaction
may lead to deadlock in the future, it is never allowed to execute.
We can prevent a Deadlock by eliminating any of the above four conditions.

 Eliminate Mutual Exclusion: It is not possible to dis-satisfy the mutual exclusion because some
resources, such as the tape drive and printer, are inherently non-shareable.
 Eliminate Hold and Wait: Allocate all required resources to the process before the start of its
execution, this way hold and wait condition is eliminated but it will lead to low device
utilization. for example, if a process requires a printer at a later time and we have allocated a
printer before the start of its execution printer will remain blocked till it has completed its
execution. The process will make a new request for resources after releasing the current set of
resources. This solution may lead to starvation.

93 | P a g e For Internal Circulation


 Eliminate No Preemption : Preempt resources from the process when resources are required by
other high-priority processes.
 Eliminate Circular Wait : Each resource will be assigned a numerical number. A process can
request the resources to increase/decrease. order of numbering. For Example, if the P1 process is
allocated R5 resources, now next time if P1 asks for R4, R3 lesser than R5 such a request will not
be granted, only a request for resources more than R5 will be granted.
 Detection and Recovery: Another approach to dealing with deadlocks is to detect and recover
from them when they occur. This can involve killing one or more of the processes involved in the
deadlock or releasing some of the resources they hold.

Deadlock Avoidance
It is better to avoid a deadlock rather than take measures after the deadlock has occurred. The wait for graph
can be used for deadlock avoidance. This is however only useful for smaller databases as it can get quite
complex in larger databases.

A deadlock avoidance policy grants a resource request only if it can establish that granting the request
cannot lead to a deadlock either immediately or in the future. The kernal lacks detailed knowledge about
future behavior of processes, so it cannot accurately predict deadlocks.
To facilitate deadlock avoidance under these conditions, it uses the following conservative approach:
Each process declares the maximum number of resource units of each class that it may require. The
kernal permits a process to request these resource units in stages- i.e. a few resource units at a time-
subject to the maximum number declared by it and uses a worst case analysis technique to check for the
possibility of future deadlocks. A request is granted only if there is no possibility of deadlocks; otherwise,
it remains pending until it can be granted. This approach is conservative because a process may complete
its operation without requiring the maximum number of units declared by it.

Resource Allocation Graph

The resource allocation graph (RAG) is used to visualize the system’s current state as a graph. The Graph
includes all processes, the resources that are assigned to them, as well as the resources that each Process
requests. Sometimes, if there are fewer processes, we can quickly spot a deadlock in the system by
looking at the graph rather than the tables we use in Banker’s algorithm. Deadlock avoidance can also be
done with Banker’s Algorithm.

94 | P a g e For Internal Circulation


Banker’s Algorithm
Bankers’s Algorithm is a resource allocation and deadlock avoidance algorithm which test all the
request made by processes for resources, it checks for the safe state, and after granting a request system
remains in the safe state it allows the request, and if there is no safe state it doesn’t allow the request
made by the process.

Inputs to Banker’s Algorithm


 Max needs of resources by each process.
 Currently, allocated resources by each process.
 Max free available resources in the system.
The request will only be granted under the below condition
 If the request made by the process is less than equal to the max needed for that process.
 If the request made by the process is less than equal to the freely available resource in the system.
Timeouts: To avoid deadlocks caused by indefinite waiting, a timeout mechanism can be used to limit
the amount of time a process can wait for a resource. If the help is unavailable within the timeout period,
the process can be forced to release its current resources and try again later.

Example:
Total resources in system:
ABCD
6576
The total number of resources are
Available system resources are:
ABCD
3112
Available resources are

Processes (currently allocated resources):


ABCD
P1 1 2 2 1
P2 1 0 3 3
P3 1 2 1 0
Maximum resources we have for a process
Processes (maximum resources):
ABCD
P1 3 3 2 2
P2 1 2 3 4
P3 1 3 5 0
Need = Maximum Resources Requirement – Currently Allocated Resources.

Need = maximum resources - currently allocated resources.


Processes (need resources):
ABCD
P1 2 1 0 1
P2 0 2 0 1
P3 0 1 4 0

95 | P a g e For Internal Circulation


UNIT V
File Systems and Input/output System :
 Files-basic concept
 file attributes, operations
 file types, file structure, access methods
 Directory- structure-single level directory system

 Directory system

File
A file is a named collection of related information that is recorded on secondary storage such as magnetic
disks, magnetic tapes and optical disks. In general, a file is a sequence of bits, bytes, lines or records whose
meaning is defined by the files creator and user.
File Structure
A File Structure should be according to a required format that the operating system can understand.
 A file has a certain defined structure according to its type.
 A text file is a sequence of characters organized into lines.
 A source file is a sequence of procedures and functions.
 An object file is a sequence of bytes organized into blocks that are understandable by the machine.
 When operating system defines different file structures, it also contains the code to support these
file structure. Unix, MS-DOS support minimum number of file structure.
File Type
File type refers to the ability of the operating system to distinguish different types of file such as text files
source files and binary files etc. Many operating systems support many types of files. Operating system
like MS-DOS and UNIX have the following types of files −
Ordinary files

 These are the files that contain user information.


 These may have text, databases or executable program.
 The user can apply various operations on such files like add, modify, delete or even remove the
entire file.
Directory files

 These files contain list of file names and other information related to these files.
Special files

 These files are also known as device files.


96 | P a g e For Internal Circulation
 These files represent physical device like disks, terminals, printers, networks, tape drive etc.
These files are of two types −
 Character special files − data is handled character by character as in case of terminals or printers.
 Block special files − data is handled in blocks as in the case of disks and tapes.
File Access Mechanisms
File access mechanism refers to the manner in which the records of a file may be accessed. There are
several ways to access files −

 Sequential access
 Direct/Random access
 Indexed sequential access
Sequential access
A sequential access is that in which the records are accessed in some sequence, i.e., the information in the
file is processed in order, one record after the other. This access method is the most primitive one.
Example: Compilers usually access files in this fashion.
Direct/Random access
 Random access file organization provides, accessing the records directly.
 Each record has its own address on the file with by the help of which it can be directly accessed for
reading or writing.
 The records need not be in any sequence within the file and they need not be in adjacent locations
on the storage medium.
Indexed sequential access

 This mechanism is built up on base of sequential access.


 An index is created for each file which contains pointers to various blocks.
 Index is searched sequentially and its pointer is used to access the file directly.
Space Allocation
Files are allocated disk spaces by operating system. Operating systems deploy following three main ways
to allocate disk space to files.

 Contiguous Allocation
 Linked Allocation
 Indexed Allocation
Contiguous Allocation

 Each file occupies a contiguous address space on disk.


 Assigned disk address is in linear order.
 Easy to implement.
 External fragmentation is a major issue with this type of allocation technique.
97 | P a g e For Internal Circulation
Linked Allocation

 Each file carries a list of links to disk blocks.


 Directory contains link / pointer to first block of a file.
 No external fragmentation
 Effectively used in sequential access file.
 Inefficient in case of direct access file.
Indexed Allocation

 Provides solutions to problems of contiguous and linked allocation.


 A index block is created having all pointers to files.
 Each file has its own index block which stores the addresses of disk space occupied by the file.
 Directory contains the addresses of index blocks of files.
Security refers to providing a protection system to computer system resources such as CPU, memory, disk,
software programs and most importantly data/information stored in the computer system. If a computer
program is run by an unauthorized user, then he/she may cause severe damage to computer or data stored
in it. So a computer system must be protected against unauthorized access, malicious access to system
memory, viruses, worms etc. We're going to discuss following topics in this chapter.

 Authentication
 One Time passwords
 Program Threats
 System Threats
 Computer Security Classifications
Authentication
Authentication refers to identifying each user of the system and associating the executing programs with
those users. It is the responsibility of the Operating System to create a protection system which ensures
that a user who is running a particular program is authentic. Operating Systems generally
identifies/authenticates users using following three ways −
 Username / Password − User need to enter a registered username and password with Operating
system to login into the system.
 User card/key − User need to punch card in card slot, or enter key generated by key generator in
option provided by operating system to login into the system.
 User attribute - fingerprint/ eye retina pattern/ signature − User need to pass his/her attribute
via designated input device used by operating system to login into the system.
One Time passwords
One-time passwords provide additional security along with normal authentication. In One-Time Password
system, a unique password is required every time user tries to login into the system. Once a one-time
password is used, then it cannot be used again. One-time password are implemented in various ways.

98 | P a g e For Internal Circulation


 Random numbers − Users are provided cards having numbers printed along with corresponding
alphabets. System asks for numbers corresponding to few alphabets randomly chosen.
 Secret key − User are provided a hardware device which can create a secret id mapped with user id.
System asks for such secret id which is to be generated every time prior to login.
 Network password − Some commercial applications send one-time passwords to user on registered
mobile/ email which is required to be entered prior to login.
Program Threats
Operating system's processes and kernel do the designated task as instructed. If a user program made these
process do malicious tasks, then it is known as Program Threats. One of the common example of
program threat is a program installed in a computer which can store and send user credentials via network
to some hacker. Following is the list of some well-known program threats.
 Trojan Horse − Such program traps user login credentials and stores them to send to malicious
user who can later on login to computer and can access system resources.
 Trap Door − If a program which is designed to work as required, have a security hole in its code
and perform illegal action without knowledge of user then it is called to have a trap door.
 Logic Bomb − Logic bomb is a situation when a program misbehaves only when certain conditions
met otherwise it works as a genuine program. It is harder to detect.
 Virus − Virus as name suggest can replicate themselves on computer system. They are highly
dangerous and can modify/delete user files, crash systems. A virus is generatlly a small code
embedded in a program. As user accesses the program, the virus starts getting embedded in other
files/ programs and can make system unusable for user
System Threats
System threats refers to misuse of system services and network connections to put user in trouble. System
threats can be used to launch program threats on a complete network called as program attack. System
threats creates such an environment that operating system resources/ user files are misused. Following is
the list of some well-known system threats.
 Worm − Worm is a process which can choked down a system performance by using system
resources to extreme levels. A Worm process generates its multiple copies where each copy uses
system resources, prevents all other processes to get required resources. Worms processes can even
shut down an entire network.
 Port Scanning − Port scanning is a mechanism or means by which a hacker can detects system
vulnerabilities to make an attack on the system.
 Denial of Service − Denial of service attacks normally prevents user to make legitimate use of the
system. For example, a user may not be able to use internet if denial of service attacks browser's
content settings.

99 | P a g e For Internal Circulation


Input/output System:
 PrinciplesofI/Ohardware
 I/Odevices,devicecontroller
 DMA,PrinciplesofI/Osoftware- goals, interrupt handler
 Devicedriver.
 Mass storage structure-disk structure
 disk scheduling

An I/O system is required to take an application I/O request and send it to the physical device, then take
whatever response comes back from the device and send it to the application. I/O devices can be divided
into two categories −
 Block devices − A block device is one with which the driver communicates by sending entire
blocks of data. For example, Hard disks, USB cameras, Disk-On-Key etc.
 Character devices − A character device is one with which the driver communicates by sending and
receiving single characters (bytes, octets). For example, serial ports, parallel ports, sounds cards etc
Device Controllers
Device drivers are software modules that can be plugged into an OS to handle a particular device.
Operating System takes help from device drivers to handle all I/O devices.
The Device Controller works like an interface between a device and a device driver. I/O units (Keyboard,
mouse, printer, etc.) typically consist of a mechanical component and an electronic component where
electronic component is called the device controller.
There is always a device controller and a device driver for each device to communicate with the Operating
Systems. A device controller may be able to handle multiple devices. As an interface its main task is to
convert serial bit stream to block of bytes, perform error correction as necessary.
Any device connected to the computer is connected by a plug and socket, and the socket is connected to a
device controller. Following is a model for connecting the CPU, memory, controllers, and I/O devices
where CPU and device controllers all use a common bus for communication.

100 | P a g e For Internal Circulation


Synchronous vs asynchronous I/O
 Synchronous I/O − In this scheme CPU execution waits while I/O proceeds
 Asynchronous I/O − I/O proceeds concurrently with CPU execution
Communication to I/O Devices
The CPU must have a way to pass information to and from an I/O device. There are three approaches
available to communicate with the CPU and Device.

 Special Instruction I/O


 Memory-mapped I/O
 Direct memory access (DMA)
Special Instruction I/O
This uses CPU instructions that are specifically made for controlling I/O devices. These instructions
typically allow data to be sent to an I/O device or read from an I/O device.
Memory-mapped I/O
When using memory-mapped I/O, the same address space is shared by memory and I/O devices. The
device is connected directly to certain main memory locations so that I/O device can transfer block of data
to/from memory without going through CPU.

While using memory mapped IO, OS allocates buffer in memory and informs I/O device to use that buffer
to send data to the CPU. I/O device operates asynchronously with CPU, interrupts CPU when finished.
The advantage to this method is that every instruction which can access memory can be used to manipulate
an I/O device. Memory mapped IO is used for most high-speed I/O devices like disks, communication
interfaces.
Direct Memory Access (DMA)
Slow devices like keyboards will generate an interrupt to the main CPU after each byte is transferred. If a
fast device such as a disk generated an interrupt for each byte, the operating system would spend most of
101 | P a g e For Internal Circulation
its time handling these interrupts. So a typical computer uses direct memory access (DMA) hardware to
reduce this overhead.
Direct Memory Access (DMA) means CPU grants I/O module authority to read from or write to memory
without involvement. DMA module itself controls exchange of data between main memory and the I/O
device. CPU is only involved at the beginning and end of the transfer and interrupted only after entire
block has been transferred.
Direct Memory Access needs a special hardware called DMA controller (DMAC) that manages the data
transfers and arbitrates access to the system bus. The controllers are programmed with source and
destination pointers (where to read/write the data), counters to track the number of transferred bytes, and
settings, which includes I/O and memory types, interrupts and states for the CPU cycles.

The operating system uses the DMA hardware as follows −

Step Description

1 Device driver is instructed to transfer disk data to a buffer address X.

2 Device driver then instruct disk controller to transfer data to buffer.

102 | P a g e For Internal Circulation


3 Disk controller starts DMA transfer.

4 Disk controller sends each byte to DMA controller.

5 DMA controller transfers bytes to buffer, increases the memory address, decreases the
counter C until C becomes zero.

6 When C becomes zero, DMA interrupts CPU to signal transfer completion.

Polling vs Interrupts I/O


A computer must have a way of detecting the arrival of any type of input. There are two ways that this can
happen, known as polling and interrupts. Both of these techniques allow the processor to deal with events
that can happen at any time and that are not related to the process it is currently running.
Polling I/O
Polling is the simplest way for an I/O device to communicate with the processor. The process of
periodically checking status of the device to see if it is time for the next I/O operation, is called polling.
The I/O device simply puts the information in a Status register, and the processor must come and get the
information.
Most of the time, devices will not require attention and when one does it will have to wait until it is next
interrogated by the polling program. This is an inefficient method and much of the processors time is
wasted on unnecessary polls.
Compare this method to a teacher continually asking every student in a class, one after another, if they
need help. Obviously the more efficient method would be for a student to inform the teacher whenever
they require assistance.
Interrupts I/O
An alternative scheme for dealing with I/O is the interrupt-driven method. An interrupt is a signal to the
microprocessor from a device that requires attention.
A device controller puts an interrupt signal on the bus when it needs CPU’s attention when CPU receives
an interrupt, It saves its current state and invokes the appropriate interrupt handler using the interrupt
vector (addresses of OS routines to handle various events). When the interrupting device has been dealt
with, the CPU continues with its original task as if it had never been interrupted.
Disk scheduling is done by operating systems to schedule I/O requests arriving for the disk. Disk
scheduling is also known as I/O scheduling.
Disk scheduling is important because:
 Multiple I/O requests may arrive by different processes and only one I/O request can be served at a
time by the disk controller. Thus other I/O requests need to wait in the waiting queue and need to be
scheduled.
 Two or more request may be far from each other so can result in greater disk arm movement.

103 | P a g e For Internal Circulation


 Hard drives are one of the slowest parts of the computer system and thus need to be accessed in an
efficient manner.
There are many Disk Scheduling Algorithms but before discussing them let’s have a quick look at some of
the important terms:
 Seek Time:Seek time is the time taken to locate the disk arm to a specified track where the data is to
be read or write. So the disk scheduling algorithm that gives minimum average seek time is better.
 Rotational Latency: Rotational Latency is the time taken by the desired sector of disk to rotate into a
position so that it can access the read/write heads. So the disk scheduling algorithm that gives
minimum rotational latency is better.
 Transfer Time: Transfer time is the time to transfer the data. It depends on the rotating speed of the
disk and number of bytes to be transferred.
 Disk Access Time: Disk Access Time is:

 Disk Response Time: Response Time is the average of time spent by a request waiting to perform its
I/O operation. Average Response time is the response time of the all requests. Variance Response
Time is measure of how individual request are serviced with respect to average response time. So the
disk scheduling algorithm that gives minimum variance response time is better.

Disk Scheduling Algorithms

1. FCFS: FCFS is the simplest of all the Disk Scheduling Algorithms. In FCFS, the requests are
addressed in the order they arrive in the disk [Link] us understand this with the help of an
example.

Example:
Suppose the order of request is- (82,170,43,140,24,16,190)
And current position of Read/Write head is : 50

So, total seek time:


=(82-50)+(170-82)+(170-43)+(140-43)+(140-24)+(24-16)+(190-16)
=642
Advantages:
 Every request gets a fair chance
 No indefinite postponement
Disadvantages:
 Does not try to optimize seek time
104 | P a g e For Internal Circulation
 May not provide the best possible service
2. SSTF: In SSTF (Shortest Seek Time First), requests having shortest seek time are executed first. So,
the seek time of every request is calculated in advance in the queue and then they are scheduled
according to their calculated seek time. As a result, the request near the disk arm will get executed
first. SSTF is certainly an improvement over FCFS as it decreases the average response time and
increases the throughput of [Link] us understand this with the help of an example.

Example:
Suppose the order of request is- (82,170,43,140,24,16,190)
And current position of Read/Write head is : 50

So, total seek time:


=(50-43)+(43-24)+(24-16)+(82-16)+(140-82)+(170-40)+(190-170)
=208
Advantages:
 Average Response Time decreases
 Throughput increases
Disadvantages:
 Overhead to calculate seek time in advance
 Can cause Starvation for a request if it has higher seek time as compared to incoming requests
 High variance of response time as SSTF favours only some requests
3. SCAN: In SCAN algorithm the disk arm moves into a particular direction and services the requests
coming in its path and after reaching the end of disk, it reverses its direction and again services the
request arriving in its path. So, this algorithm works as an elevator and hence also known as elevator
algorithm. As a result, the requests at the midrange are serviced more and those arriving behind the
disk arm will have to wait.

Example:

105 | P a g e For Internal Circulation


Suppose the requests to be addressed are-82,170,43,140,24,16,190. And the Read/Write arm is at 50,
and it is also given that the disk arm should move “towards the larger value”.

Therefore, the seek time is calculated as:

=(199-50)+(199-16)
=332
Advantages:
 High throughput
 Low variance of response time
 Average response time
Disadvantages:
 Long waiting time for requests for locations just visited by disk arm
4. CSCAN: In SCAN algorithm, the disk arm again scans the path that has been scanned, after reversing
its direction. So, it may be possible that too many requests are waiting at the other end or there may be
zero or few requests pending at the scanned area.
These situations are avoided in CSCAN algorithm in which the disk arm instead of reversing its direction
goes to the other end of the disk and starts servicing the requests from there. So, the disk arm moves in a
circular fashion and this algorithm is also similar to SCAN algorithm and hence it is known as C-SCAN
(Circular SCAN).
Example:

106 | P a g e For Internal Circulation


Suppose the requests to be addressed are-82,170,43,140,24,16,190. And the Read/Write arm is at 50, and it
is also given that the disk arm should move “towards the larger value”.

Seek time is calculated as:


=(199-50)+(199-0)+(43-0)
=391
Advantages:
 Provides more uniform wait time compared to SCAN
5. LOOK: It is similar to the SCAN disk scheduling algorithm except for the difference that the disk
arm in spite of going to the end of the disk goes only to the last request to be serviced in front of the
head and then reverses its direction from there only. Thus it prevents the extra delay which occurred
due to unnecessary traversal to the end of the disk.

Example:
Suppose the requests to be addressed are-82,170,43,140,24,16,190. And the Read/Write arm is at 50,
and it is also given that the disk arm should move “towards the larger value”.

So, the seek time is calculated as:


=(190-50)+(190-16)
=314

107 | P a g e For Internal Circulation


6. CLOOK: As LOOK is similar to SCAN algorithm, in similar way, CLOOK is similar to CSCAN
disk scheduling algorithm. In CLOOK, the disk arm in spite of going to the end goes only to the last
request to be serviced in front of the head and then from there goes to the other end’s last request.
Thus, it also prevents the extra delay which occurred due to unnecessary traversal to the end of the
disk.

Example:
Suppose the requests to be addressed are-82,170,43,140,24,16,190. And the Read/Write arm is at 50,
and it is also given that the disk arm should move “towards the larger value”

So, the seek time is calculated as:


=(190-50)+(190-16)+(43-16)
=341

108 | P a g e For Internal Circulation


PRACTICE QUESTIONS

1) Explain the main purpose of an operating system?


Operating systems exist for two main purposes. One is that it is designed to make sure a computer system
performs well by managing its computational activities. Another is that it provides an environment for the
development and execution of programs.

2) What is demand paging?


Demand paging is referred when not all of a process’s pages are in the RAM, then the OS brings the
missing(and required) pages from the disk into the RAM.

3) What are the advantages of a multiprocessor system?


With an increased number of processors, there is a considerable increase in throughput. It can also save
more money because they can share resources. Finally, overall reliability is increased as well.

4) What is kernel?
A kernel is the core of every operating system. It connects applications to the actual processing of data. It
also manages all communications between software and hardware components to ensure usability and
reliability.

5) What are real-time systems?


Real-time systems are used when rigid time requirements have been placed on the operation of a processor.
It has well defined and fixed time constraints.

6) What is a virtual memory?

Virtual memory is a memory management technique for letting processes execute outside of memory. This
is very useful especially is an executing program cannot fit in the physical memory.

7) Describe the objective of multiprogramming.


The main objective of multiprogramming is to have a process running at all times. With this design, CPU
utilization is said to be maximized.

8 ) What is time- sharing system?


In a Time-sharing system, the CPU executes multiple jobs by switching among them, also known as
multitasking. This process happens so fast that users can interact with each program while it is running.

9) What is SMP?
SMP is a short form of Symmetric Multi-Processing. It is the most common type of multiple-processor
systems. In this system, each processor runs an identical copy of the operating system, and these copies
communicate with one another as needed.
109 | P a g e For Internal Circulation
10) How are server systems classified?
Server systems can be classified as either computer-server systems or file server systems. In the first case,
an interface is made available for clients to send requests to perform an action. In the second case,
provisions are available for clients to create, access and update files.

11) What is asymmetric clustering?


In asymmetric clustering, a machine is in a state known as hot standby mode where it does nothing but to
monitor the active server. That machine takes the active server’s role should the server fails.

12) What is a thread?


A thread is a basic unit of CPU utilization. In general, a thread is composed of a thread ID, program
counter, register set, and the stack.

13) Give some benefits of multithreaded programming.


– there is increased responsiveness to the user
– resource sharing within the process
– economy
– utilization of multiprocessing architecture

14) Briefly explain FCFS.


FCFS stands for First-come, first-served. It is one type of scheduling algorithm. In this scheme, the process
that requests the CPU first is allocated the CPU first. Implementation is managed by a FIFO queue.

15) What is RR scheduling algorithm?


RR (round-robin) scheduling algorithm is primarily aimed for time-sharing systems. A circular queue is a
setup in such a way that the CPU scheduler goes around that queue, allocating CPU to each process for a
time interval of up to around 10 to 100 milliseconds.

16) What are necessary conditions which can lead to a deadlock situation in a system?
Deadlock situations occur when four conditions occur simultaneously in a system: Mutual exclusion; Hold
and Wait; No preemption; and Circular wait.

17) What factors determine whether a detection-algorithm must be utilized in a deadlock avoidance
system?
One is that it depends on how often a deadlock is likely to occur under the implementation of this
algorithm. The other has to do with how many processes will be affected by deadlock when this algorithm
is applied.

18) State the main difference between logical from physical address space.
Logical address refers to the address that is generated by the CPU. On the other hand, physical address
refers to the address that is seen by the memory unit.

19) How does dynamic loading aid in better memory space utilization?

110 | P a g e For Internal Circulation


With dynamic loading, a routine is not loaded until it is called. This method is especially useful when large
amounts of code are needed in order to handle infrequently occurring cases such as error routines.

20) What is the basic function of paging?


Paging is a memory management scheme that permits the physical address space of a process to be
noncontiguous. It avoids the considerable problem of having to fit varied sized memory chunks onto the
backing store.

111 | P a g e For Internal Circulation


MCQs
SET A
1. In the case of the index allocation scheme of various blocks to a file, the maximum size
(possible) of the file would depend on :

a. the total number of blocks that have been used for the index, size of all the blocks

b. the actual size of all blocks, the size of the blocks’ address

c. the of the blocks’ size, the blocks’ address size, and the total number of blocks that have been
used for the index

d. None of the above

Answer: (a) the total number of blocks that have been used for the index, size of all the blocks

2. The swap space in a disk is primarily used to:

a. Save process data

b. Save temporary HTML pages

c. Store the device drivers

d. Store the super-block

Answer: (a) Save process data

3. Out of these page replacement algorithms, which one suffers from Belady’s anomaly?

a. LRU

b. FIFO

c. Both LRU and FIFO

d. Optimal Page Replacement

Answer: (b)FIFO

4. An increase in a computer’s RAM leads to a typical improvement in performance because:


112 | P a g e For Internal Circulation
a. Fewer page faults occur

b. Virtual memory increases

c. Fewer segmentation faults occur

d. A larger RAM is faster

Answer: (a) Fewer page faults occur

5. Consider a computer system that supports 32-bit physical as well as virtual addresses. Now
since the space of the physical address is the same size as the virtual address, the OS designers
would decide to entirely get rid of its virtual memory. Which one of these is true in this case?

a. It is no longer possible to efficiently implement multi-user support

b. It is possible to make CPU scheduling more efficient now

c. There would no longer be a requirement for hardware support for memory management

d. It would be possible to make the processor cache organisation more efficient now

Answer: (c) There would no longer be a requirement for hardware support for memory
management

6. The Virtual memory is:

a. An illusion of a large main memory

b. A large main memory

c. A large secondary memory

d. None of the above

Answer: (a) An illusion of a large main memory

7. A CPU yields 32-bit virtual addresses, and the page size is 4 kilobytes. Here, the processor
consists of a TLB (translation lookaside buffer). It is a 4-way set associative, and it can hold a
total of 128-page table entries. The TLB tag’s minimum size is:

a. 20 bits

113 | P a g e For Internal Circulation


b. 15 bits

c. 13 bits

d. 11 bits

Answer: (b) 15 bits

8. Thrashing occurs in a system when:

a. The processes on the system access pages and not memory frequently

b. A page fault pops up

c. The processes on the system are in running state

d. The processes on the system are in the waiting state

Answer: (a) The processes on the system access pages and not memory frequently

9. The page fault occurs whenever:

a. The requested page isn’t in the memory

b. The requested page is in the memory

c. An exception is thrown

d. The page is corrupted

Answer: (a) The requested page isn’t in the memory

10. Consider a computer that uses 32–bit physical address, 46–bit virtual address, along with a
page table organisation that is three-level. Here, the base register of the page table stores the T1
(first–level table) base address, which occupies exactly one page. Every entry of the T1 stores the
T2 (second-level table) page’s base address. Similarly, every entry of T2 stores the T3 (third-level
table) page’s base address and every entry of T3 stores a PTE (page table entry). The size of
PTE is 32 bits. In the computer, the processor has a 1 MB 16 way virtually indexed set-
associative physically tagged cache. If the size of the cache block is 64 bytes, then what is the
size of a page in this computer in Kilobytes?

a. 4
114 | P a g e For Internal Circulation
b. 2

c. 16

d. 8

Answer: (d) 8

11. Consider that the page fault service time in a computer is 10ms and the average memory
access time is 20ns. If, in case, it generates a page fault every 10^6 memory accesses, then what
would be the effective access time for this memory?

a. 30ns

b. 21ns

c. 35ns

d. 23ns

Answer: (a) 30ns

12. FIFO policy is used in a system for page replacement. It consists of 4-page frames, and no
pages loaded, to start with. This system initially accesses 100 separate pages in a particular
order. It then accesses these same 100 pages. The difference is that now they are in the reverse
order. Considering this, how many page faults would occur here?

a. 192

b. 195

c. 196

d. 197

Answer: (c) 196

13. In every entry of a page table, the essential content(s) is/are:

a. Page frame number

b. Virtual page number

115 | P a g e For Internal Circulation


c. Both page frame number and virtual page number

d. Accessing the right information

Answer: (a) Page frame number

14. When translating a virtual address to a physical address, a multilevel page table is always a
preference as compared to a single level page because it:

a. Helps in the reduction of the total page faults in the page replacement algorithms

b. Reduces the total memory access time for reading or writing a memory location

c. Helps in the reduction of the page table size required for implementing a process’s virtual
address space

d. Is required by the lookaside buffer translation

Answer: (c) Helps in the reduction of the page table size required for implementing a process’s
virtual address space

15. Consider a processor that uses 32-bit virtual addresses, 36-bit physical addresses, and a 4
KB page frame size. Each page table entry is 4 bytes in size. Here, a page table of three-level is
used for the translation of virtual to a physical address. The virtual address, in this case, is used
as follows:

• Bits 12-20 are utilised for indexing into the page table of the third level

• Bits 21-29 are utilised for indexing into the page table of the second level

• Bits 30-31 are utilised for indexing into the page table of the first level, and • Bits 0-11 are
utilised as an offset within the page.

Thus, the total number of bits needed to address the next level page frame or page table for the
first-level, second-level and third-level page table entry are respectively:

a. 25, 25 and 24

b. 24, 24 and 20

c. 24, 24 and 24

116 | P a g e For Internal Circulation


d. 20, 20 and 20

Answer: (c) 24, 24 and 24

16. Consider that a virtual memory system uses a FIFO page replacement policy. For a process,
it allocates a fixed number of frames. Now consider these statements:

A: An increase in the number of page frames that are allocated to a

process sometimes leads to an increase in the page fault rate.

B: A few programs do not display the locality of reference.

Which one of these statements is TRUE?

a. A is false, but B is true

b. Both A and B are false

c. Both A and B are true, and B is the reason for A

d. Both A and B are true, but B isn’t the reason for A

Answer: (d)Both A and B are true, but B isn’t the reason for A

17. 3 page frames have been allocated to a process. Here, we assume that none of the process’s
pages is available initially in the memory, and the process creates this sequence of page
references: 1, 2, 1, 3, 7, 4, 5, 6, 3, 1 (reference string). If an optimal page replacement policy is
utilised, then how many page faults would occur for the reference string mentioned above?

a. 10

b. 9

c. 8

d. 7

Answer: (d) 7

18. Consider paging hardware that has a TLB. Let us assume that the page table and the pages
are in their physical memory. Searching the TLB takes 10 milliseconds, and accessing the

117 | P a g e For Internal Circulation


physical memory takes 80 milliseconds. In case the TLB hit ratio is 0.6, then the effective memory
access time is _________ (in milliseconds).

a. 124

b. 122

c. 120

d. 118

Answer: (b) 122

19. A system that has 32-bit virtual addresses & 1 KB page size, it is not practical to use one-level
page tables for translating virtual to a physical address, due to:

a. a large amount of external fragmentation

b. a large amount of internal fragmentation

c. a large computation overhead in the process of translation

d. a large memory overhead when maintaining the page tables

Answer: (d)a large memory overhead when maintaining the page tables

20. Which of these isn’t an advantage of using dynamically linked, shared libraries, as compared
to statically linked libraries?

a. Faster program startup

b. The existing programs do not need to be re-linked so as to take advantage of the newer library
versions

c. Lesser page fault rate in a system

d. Smaller sizes of executable files

Answer: (a) Faster program startup

21. Out of all the following, which one isn’t a form of memory?

a. translation lookaside buffer


118 | P a g e For Internal Circulation
b. instruction opcode

c. instruction register

d. instruction cache

Answer: (b)instruction opcode

22. The process of dynamic linking can generate security concerns because:

a. Linking is insecure

b. The cryptographic procedures aren’t available for the process of dynamic linking

c. Security is dynamic

d. The path of the searching dynamic libraries isn’t known until the runtime

Answer: (b)The cryptographic procedures aren’t available for the process of dynamic linking

23. Which of these is a false statement?

a. The virtual memory translates a program‘s address space into their physical memory address
space.

b. The virtual memory allows every program to exceed the primary memory’s size.

c. The virtual memory leads to an increase in the degree of multiprogramming

d. The virtual memory leads to a reduction of the context switching overhead

Answer: (d)The virtual memory leads to a reduction of the context switching overhead

24. ________ is the process in which load addresses are assigned to a program’s various parts,
and the code and date are adjusted in the program for the reflection of the assigned addresses.

a. Symbol resolution

b. Assembly

c. Parsing

d. Relocation
119 | P a g e For Internal Circulation
Answer: (d)Relocation

25. Which one of these is NOT shared by the same process’s threads?

a. Address Space

b. Stack

c. Message Queue

d. File Descriptor Table

Answer: (b)Stack

26. In the case of a particular Unix OS, every data block is 1024 bytes in size. Every node
consists of 10 direct data block addresses along with three additional addresses: one for a triple,
one for double, and one for a single indirect block. Each block here can consist of addresses for
128 blocks. Out of the following, which one is the approximate maximum size of the files in a file
system?

a. 16 GB

b. 8 GB

c. 2 GB

d. 512 MB

Answer: (c) 2GB

27. Which of these disk scheduling policies results in minimum head movement?

a. Circular scan

b. Elevator

c. FCS

d. None of the above

Answer: (a) Circular scan

120 | P a g e For Internal Circulation


28. Consider a hard disk that has 63 sectors/track. It has 10 platters each – 2 recording surfaces
& 1000 cylinders. A sector’s address is displayed as a triple (c, h, s). Here, c refers to the cylinder
number, h refers to the surface number, and s refers to the sector number. The 0th sector here is
addressed as (0, 0, 0), then the 1st sector will be addressed as (0, 0, 1), and so on. According to
this, the address (400,16,29) would correspond to the sector number:

a. 505038

b. 505037

c. 505036

d. 505035

Answer: (b)505037

29. In a magnetic disk that consists of concentric circular tracks, its seek latency isn’t proportional
linearly to the seek distance, because of:

a. the use of arm scheduling policies that are unfair

b. a higher track capacity on the platter’s periphery

c. a starting and stopping inertia for arms

d. a non-uniform distribution of all the requests

Answer: (c) a starting and stopping inertia for arms

30. Out of the following statements, which ones are NOT true about asynchronous and
synchronous I/O?

a. In a synchronous I/O, any process that is waiting for the I/O’s completion is woken up by the
Interrupt Service Routine that is invoked after the I/O gets completed.

b. The processes that make the synchronous I/O call wait until I/O gets completed, but the
processes that make an asynchronous I/O call don’t wait for the completion of the I/O.

c. In both asynchronous and synchronous I/O, an Interrupt Service Routine (ISR) is invoked after
the I/O is finally completed.

121 | P a g e For Internal Circulation


d. The ISR is invoked after completing the I/O in synchronous I/O. It does not do so in the case of
asynchronous I/O.

Answer: (d) The ISR is invoked after completing the I/O in synchronous I/O. It does not do so in
the case of asynchronous I/O.

31. The usage of some larger block size in a file system of a fixed block size leads to:

a. a better disk space utilisation but poorer disk throughput

b. a poorer disk space utilisation and poorer disk throughput

c. a poorer disk space utilisation but better disk throughput

d. a better disk space utilisation and better disk throughput

Answer: (c) a poorer disk space utilisation but better disk throughput

32. Out of the following, which one needs a device driver?

a. Main memory

b. Disk

c. Register

d. Cache

Answer: (b)Disk

33. The onboard memory of a graphics card is about 1 MB. Out of the modes mentioned below,
which one does the card not support?

a. A resolution of 1600 x 400 and a 17-inch monitor with 256 colours.

b. A resolution of 1600 x 400 and a 14-inch monitor with 16 million colours.

c. A resolution of 800 x 400 and a 17-inch monitor with 16 million colours.

d. A resolution of 800 x 800 and a 14-inch monitor with 256 colours.

Answer: (b) A resolution of 1600 x 400 and a 14-inch monitor with 16 million colours.

122 | P a g e For Internal Circulation


34. Out of the following interrupt handling mechanisms and DMA transfer modes, which one
enables the highest bandwidth for I/O:

a. Polling interrupts and Transparent DMA

b. Vectored interrupts and Cycle-stealing

c. Vectored interrupts and Block transfer

d. Polling interrupts and Block transfer

Answer: (c) Vectored interrupts and Block transfer

35. Assume three processes with process IDs 0, 1, and 2, respectively. They have computed time
bursts of 2, 4, and 8 units, and all the processes arrive at time 0. Now consider the LRTF (longest
remaining time first) scheduling algorithm. In the case of LRTF, the ties are broken by prioritising
the process that has the lowest process ID. Here, the average turnaround time would be:

a. 16 units

b. 15 units

c. 14 units

d. 13 units

Answer: (d)13 units

36. Out of these statements, which ones are/is true?

P. The shortest remaining time in the first scheduling may lead to starvation

Q. Preemptive scheduling may lead to starvation

R. In terms of responsive time, Round robin is comparatively much better than FCFS

a. P only

b. P and R only

c. Q and R only

d. P, Q and R
123 | P a g e For Internal Circulation
Answer: (d)P, Q and R

37. An OS utilises the SRT or Shortest Remaining Time first process scheduling algorithm. Let us
consider the execution time and arrival time for these processes:

Process Arrival time Execution time

P1 : 0 20

P2 : 15 25

P3 : 30 10

P4 : 45 15

The total waiting time for the P2 process would be:

a. 55

b. 40

c. 15

d. 5

Answer: (c) 15

38. In a computer system that consists of n number of CPUs, the maximum processes that can
exist in the Ready State would be:

a. Independent of n

b. 2n

c. n^2

d. n

Answer: (a) Independent of n

39. Out of the following, which one is FALSE about Shortest Job First Scheduling (SJF)?

X1: It can lead to starvation


124 | P a g e For Internal Circulation
X2: It can lead to a minimum average waiting time

a. Only X1

b. Only X2

c. Neither X2 nor X1

d. Both X2 and X1

Answer: (c) Neither X2 nor X1

40. In a process, the following code is executed:

fork();

fork();

fork();

As a result, a total of _______ number of child processes will be created.

a. 8

b. 7

c. 4

d. 3

Answer: (b)7

41. The total time taken for switching between the user and the kernel modes of execution is t1,
while the total time taken for switching between two processes is t2. Out of the following, which
one is TRUE?

a. t2 > t1

b. t2 = t1

c. t2 < t1

d. We cannot say anything about the relation between t2 and t1


125 | P a g e For Internal Circulation
Answer: (a) t2 > t1

42. We can define a thread as a “lightweight process”. It is because an OS (operating system)


maintains much shorter data structures for a thread instead of a process. Concerning this, which
of the following statements is TRUE?

a. The Operating System maintains only the CPU register state on a per-thread basis

b. The OS does not maintain each thread’s separate stack

c. The Operating System does not maintain a virtual memory state on a per-thread basis

d. The Operating System maintains only accounting and scheduling information on a per-thread
basis

Answer: (c) The Operating System does not maintain a virtual memory state on a per-thread
basis

43. Which one of these statements about kernel-level threads and user-level threads is FALSE?

a. The context switch time is comparatively longer for the kernel-level threads, as compared to the
ones for the user-level threads.

b. The user-level threads don’t require any support for hardware.

c. We can schedule the related kernel-level threads in a multi-processor system on different


processors.

d. When one kernel-level thread is blocked, then all the related threads will be blocked.

Answer: (d) When one kernel-level thread is blocked, then all the related threads will be blocked.

44. Which of these doesn’t interrupt a running process?

a. Power failure

b. Scheduler process

c. Timer

d. A device

Answer: (b)Scheduler process


126 | P a g e For Internal Circulation
45. Which of these need not be saved necessarily during context switching between various
processes?

a. Translation look-aside buffer

b. General-purpose registers

c. Program counter

d. None of the above

Answer: (a) Translation look-aside buffer

46. In the case of a working-set strategy, which of these is done by the OS to prevent thrashing?

P. If there are enough extra frames, it initiates another process.

Q. It selects any process for suspending in case the sum of the working sets’ sizes exceed the
number of available frames.

a. P only

b. Q only

c. Neither P nor Q

d. Both P and Q

Answer: (d)Both P and Q

47. An OS implements a policy that needs a process to release all of the resources before it
makes any requests for another resource. Out of all the statements below, select the one that is
TRUE:

a. Both deadlock and starvation can occur

b. Deadlock cannot occur, but starvation can occur

c. Deadlock can occur, but starvation cannot occur

d. Neither deadlock nor starvation can occur

Answer: (b)Deadlock cannot occur, but starvation can occur


127 | P a g e For Internal Circulation
48. Multiple words are put in a single cache block for:

a. reducing the miss penalty

b. exploiting the reference’s temporal locality in a program

c. exploiting the reference’s spatial locality in a program

d. none of the above

Answer: (c) exploiting the reference’s spatial locality in a program

49. The lowest number of page frames that are bound to be allocated in an environment of virtual
memory to a running process is determined by:

a. the page size

b. the instruction set architecture

c. the total number of processes in memory

d. the size of the physical memory

Answer: (b)the instruction set architecture

50. Consider a file whose ordering key field is 10 bytes long, the primary index has been created
for the file, and the block pointer is 6 bytes long. In this case, if we wish to search a record with
the help of an index, then how many block access do we require?

a. 11

b. 10

c. 9

d. 8

Answer: (b)10

128 | P a g e For Internal Circulation


SET B

Q1. What is the most used computer operating system?

1. Linux
2. Windows
3. Chrome os
4. Android

Answer: b) Windows as windows seems to be the only operating system on which most
applications are built and are built for. Windows has been one of the most used operating
systems as it has evolved completely from its earlier versions that were released decades ago.

Q2. What was the first operating system?

1. Linux
2. Windows
3. GM NAA I/O
4. Android

Answer: c) GM NAA I/O as windows seem to be the first operating system which was built
around the mid-’50s of 20th century for IBM 704. IT was built by a general motors research
division. These were made for IBM computers for batch processing which means starting one
process once the previous process is finished.

Q3. When was the first operating system built?

1. 1956
2. 1950
3. 1952
4. 1960

Answer: a) 1956 as the first operation was developed in the year 1956 for IBM 704 as these were
used for basic input-output functions. These were widely used around these times for carrying out
basic functions like making use of basic input-output functions by the process of batch
processing.

Q4. What is the first windows version?

129 | P a g e For Internal Circulation


1. Windows NT
2. Windows 3.0
3. Windows 1.01
4. Windows XP

Answer: c) Windows 1.01. The first Windows version was built around the year 1985, and it
marked a historical development in the field of software programming as it was one of the most
advanced operating systems that were ever made.

Q5. What does an operating system do?

1. An interface that regulates hardware and software programs


2. A hardware device
3. A program that operates the hardware devices
4. All of the above

Answer. a) an interface that regulates hardware and software changes. The operating system
seems to be a software program that links all the hardware and software devices to produce an
interface that will help in managing all the devices in a proper manner.

Q6. What type of extension name do notepads use?

1. .png
2. .txt
3. .jpeg
4. .xip

Answer. b) .txt. Every program that produces output like a photo or a text can be saved using
different extension types. The notepad uses the .txt format, which means “text”. These are widely
used formats for recording texts on an operating system.

Q7. What is the full form of BIOS?

1. Between input-output system


2. Binary input-output system
3. Basic input/output system
4. All of the above

130 | P a g e For Internal Circulation


Answer. c) Basic input/output system. The bios seem to be referred to as basic input and output
system as it is used to start startup procedures that are important for an operating system to run
properly.

Q8. What does FAT mean?

1. File format attribute


2. Font allocation tree
3. File allocation table
4. Font attribute table

Answer. c) File allocation table. The file allocation table, which is full of FAT, is a file system that
seems to be maintained on the hard drive that has clusters of all the files located on it.

Q9. Who needs a BIOS to function properly?

1. A mobile device
2. An operating system
3. Hardware devices
4. All of the above

Answer. b) an operating system. The operating system has a requirement of BIOS that handles
all the basic input and output as the bios helps in starting important hardware processes before
the operating system boots up [Link] are intrinsic to the functioning of the complete OS
as they help in maintaining a proper link between the hardware and software.

Q10. What does restarting an operating system do?

1. Restarts all the processes


2. Shuts down the operating system completely
3. Terminates all running programs completely
4. All of the above

Answer. a) restarts all the processes. When the restart button is hit on an operating system, the
operating system receives a command to restart all the processes completely by restarting the
whole operating system. When the computer is restarted, all the processes running within the
system are terminated effectively so that the operating system can reboot.

Q11. What operations mentioned are done by an operating system?


131 | P a g e For Internal Circulation
1. Maintaining recycle bin
2. Transfer files
3. Opens a program
4. All of the above

Answer. d) all of the above. The operating system can do all the above-mentioned activities like
maintaining a recycle bin, transferring files from one pc to another as well as opening different
programs.

Q12. Where are the errors and bugs recorded?

1. notepad
2. New program
3. Running process
4. Logfile

Answer. d) lof file. The operating system will always record the generated bugs or errors on a log
file when an operating system finds any kinds of errors. The log file acts as a record for all the
errors caused consciously or unconsciously by the user or the operating system. These log files
can later be used to fix unknown bugs and errors by the developers.

Q13. Which one of the following isn’t considered a real-time operating system?

1. PSOS
2. linuxRT
3. VRTX
4. Windows

Answer. d) Windows. The window operating system isn’t considered a real-time operating
system as it can remain unresponsive completely from durations which isn’t a property that real-
time operating systems have. All other three Operating systems mentioned can operate in real
time without pausing and are hence used in major technical scenarios that need constant
computing power on a daily basis.

Q14. What are the properties of processes in an operating system?

1. Global variables, personal address


2. Shutdown
3. Restarting services
132 | P a g e For Internal Circulation
4. All of the above

Answer. a) global variables and personal address. The processes in an operating system seem
to have their own global variables and address spacing making them independent processing
units that can perform different tasks at once.

Q15. What are file extensions?

1. Log files
2. Output types for file formats
3. Software programs
4. All of the above

Answer. b) Output types for file formats. The file extensions act as output formats for various
types of file formats, the file types have different suffix attached to them that represent the
extension type.

Q16. What is a batch operating system?

1. Multiple individual tasks


2. Similar types of tasks are grouped together
3. Tasks operating at different systems
4. All of the above

Answer. b) Similar types of tasks grouped together. The batch operating system was the first
type of OS system invented around the 1950s that helped in grouping similar types of tasks under
one process and automated the whole group together.

Q17. What is a time sharing operating system?

1. Makes use of log files to do basic task


2. One shell seems to be shared
3. Allows users to use one system with two different terminals
4. All of the above

Answer. c) Allows users to use one system with two different terminals. The time sharing
operating system helps in the usage of one system with the help of multiple shells used by
multiple users. The CPU processing time is used by multiple users at once.

133 | P a g e For Internal Circulation


Q18. What of the following isn’t directly related to the operating system?

1. BIOS
2. Software programs
3. Hardware devices
4. All of the above

Answer. c) hardware devices. The hardware devices are independent components that aren’t
inherently related to an operating system and have their own individual functions without the
presence of an operating system, even though they require an os for proper functioning.

Q19. What makes an operating system whole?

1. Log files
2. Input devices
3. Output devices
4. All of the above

Answer. d) All of the above. An operating system is a mixture of all input devices and output
devices along with various log files and services that are important for the proper functioning of
the operating system.

Q20. What is FIFO scheduling?

1. First input-output scheduling


2. First in first out scheduling
3. Free input free output
4. All of the above

Answer. b) First in first out scheduling. First in first out scheduling seems to be a type of
algorithm used to group processes in queues and order them in a way that the first process that
comes in is the first one that gets processed and is outputted immediately for the other process to
run.

134 | P a g e For Internal Circulation


FORMAT OF INTERNAL QUESTION PAPER

1stInternal Examination (2020)

Course: Semester:
Subject: Course Code:
Max. Marks: 40 Max. Time: 2 Hours

Instructions (if any):- Use of calculator for subjects like Financial Mgt. Operation etc. allowed if required.
(Scientific calculator is not allowed).
Use of unfair means will lead to cancellation of paper followed by disciplinary action.
Question No. 1 is compulsory. Attempt any two questions from Q2 to Q5.
Attempt any two question from section 2.
Section 1
(Theoretical Concept and Practical/Application oriented)
Answer in 400 words. Each question carry 06 marks.
Q. 1
Q. 2
Q.3
Q. 4
Q.5 Write Short Note on any two. Answer in 300 words. Each carry 03 marks.
a)
b)
c)

Section 2
(Analytical Question / Case Study / Essay Type Question to test analytical and Comprehensive
Skills)

Answer in 800 words. Attempt any 2 [Link] question carry 11 marks


Q6.
Q7.
Q8.

135 | P a g e For Internal Circulation


PREVIOUS YEAR UNIVERSITY QUESTION PAPERS

136 | P a g e For Internal Circulation


137 | P a g e For Internal Circulation
138 | P a g e For Internal Circulation
139 | P a g e For Internal Circulation
140 | P a g e For Internal Circulation
141 | P a g e For Internal Circulation
142 | P a g e For Internal Circulation
143 | P a g e For Internal Circulation
144 | P a g e For Internal Circulation
145 | P a g e For Internal Circulation
Previous year Internal Question papers
1st Internal Examination (2019)

Course: BCA Semester: III


Subject: Operating Systems Course Code: 301
Max. Marks: 40 Max. Time: 2 Hours

Instructions (if any):- Use of unfair means will lead to cancellation of paper followed by
disciplinary action.
Question No. 1 is compulsory. Attempt any two questions from Q2 to Q5.
Attempt any two question from section 2.
Section 1
Answer in 400 words. Each question carry 06 marks.
Q. 1 Explain static and dynamic relocation.
Q. 2 What do you understand by input output interface?
Q.3 Explain various file access methods.
Q. 4 What do you understand by swapping?
Q.5 Write Short Note on any two. Answer in 300 words. Each carry 03 marks.
a) Internal Fragmentation
b) First fit and next fit
c) File types

Section 2

Answer in 800 words. Attempt any 2 questions. Each question carry 11 marks
Q. 6 What do you understand by deadlocks? Explain deadlock prevention, deadlock avoidance and
deadlock detection & recovery?
Q. 7 Explain interrupt driven I/O and DMA?
Q. 8 Suppose that a disk drive has 50 tracks. The system refers the tracks in following sequence:
25,37,15,9,24,37,39,47,13,25,15
Currently head is on track number 20 and moving outside. Calculate total track movements and time
required to move all these tracks. (Consider seek time = 0.15 ms) in case of:
 Shortest seek time first

146 | P a g e For Internal Circulation


1st Internal Examination (2019)

Course: BCA Semester: III


Subject: Operating Systems Course Code: 301
Max. Marks: 40 Max. Time: 2 Hours

Instructions (if any):- Use of calculator for subjects like Financial Mgt. Operation etc. allowed if
required. (Scientific calculator is not allowed).
Use of unfair means will lead to cancellation of paper followed by disciplinary action.
Question No. 1 is compulsory. Attempt any two questions from Q2 to Q5.
Attempt any two question from section 2.
Section 1
Answer in 400 words. Each question carry 06 marks.
Q. 1 Explain operating system services for process management.
Q. 2 What are different states of a process?
Q.3 Explain SJF and Multilevel Scheduling algorithms?
Q. 4 Explain Different types of operating systems.
Q.5 Write Short Note on any two. Answer in 300 words. Each carry 03 marks.
a) Paging
b) ABORT System Call
c) Network OS

Section 2

Answer in 800 words. Attempt any 2 questions. Each question carry 11 marks
Q6. Explain different types of schedulers with the help of diagram.
Q7. Explain Virtual memory, demand paging, page replacement and page replacement algorithms.
Q8. What is PCB? Explain what type of information is stored in PCB?

147 | P a g e For Internal Circulation


1st Internal Examination (February, 2020)
(2014 Course)
Course: BCA Semester: III
Subject: Operating Systems Course Code: 301
Max. Marks: 40 Max. Time: 2 Hours
Instructions (if any):- Use of calculator for subjects like Financial Mgt. Operation etc. allowed if
required. (Scientific calculator is not allowed).
Use of unfair means will lead to cancellation of paper followed by disciplinary action.
Question No. 1 is compulsory. Attempt any two questions from Q2 to Q5.
Attempt any two question from section 2.
Section 1
Answer in 400 words. Each question carry 06 marks.
Q. 1 Explain Multitasking and multiprocessing operating systems.
Q. 2 What are different states of a process?
Q.3 Explain SRTN and FCFS scheduling algorithms?
Q. 4 Explain Functions of operating systems.
Q.5 Write Short Note on any two. Answer in 300 words. Each carry 03 marks.
a) Suspend System Call
b) Resume System Call
c) Real time OS

Section 2

Answer in 800 words. Attempt any 2 questions. Each question carry 11 marks
Q6. Explain different types of schedulers with the help of diagram.
Q7. Explain different views of operating systems.
Q8. Explain the concept of a process, process relationship and implicit and explicit tasking.

148 | P a g e For Internal Circulation


BharatiVidyapeeth(Deemed to be University)
Institute of Management and Research (BVIMR), New Delhi
1stInternal Examination (September, 2018)
Course: BCA Semester: III
Subject: Operating System Concepts Course Code: 301
Max. Marks: 40 Max. Time: 2 Hours

Q. 1 Attempt any five questions. Answer in 50 words (Recall) [5 x 2]

a) What do you understand by monitors?


b) What is process relationship?
c) What is inter process communication?
d) What is implicit and explicit tasking?
e) Explain in brief about batch operating system.
f) Explain inter-process signaling.
g) Explain in brief about SJF scheduling algorithm.
h) What is the difference between preemptive and non preemptive scheduling algorithm?

Q. 2 attempt any two question. Answer in 200 words (Theoretical Concept) [2 x 5]

a) Explain different views of operating system.


b) Explain the process concept. What are various process management functions performed by operating
system?
c) Explain process states with the help of diagram.
Q.3 Attempt any two questions. Answer in 200 words (Practical/Application oriented) [2 x 5]

a) Explain PCB in Detail


b) Write any 5 operating system services for process management?
c) Write an algorithm to achieve mutual exclusion with semaphores.
d) What are the various services provided by operating system?

Q.4 Attempt any one. Answer in 600 words (Analytical Question / Case Study / Essay Type Question to test
analytical and Comprehensive Skills) [1x10]
a) Explain different types of schedulers with the help of diagram? Also explain round robin, SRTN and MLQ
scheduling with the help of diagram.
b) Write short notes on any two of the following :
i) Multiprocessing
ii) Mutual Exclusion
iii) Scheduling and performance criteria

149 | P a g e For Internal Circulation


BharatiVidyapeeth(Deemed to be University)
Institute of Management and Research (BVIMR), New Delhi
2nd Internal Examination (October 2018)

Course : BCA Semester : III


Subject: Operating System Concepts Course Code: 301
Max. Marks: 40 Max. Time: 2 Hours

Instructions (if any):- (accounting, mathematics regarding use of Calculator, if required). Give
Examples & Diagrammatic Representations wherever as possible

Question No. 1 is compulsory. Attempt any two questions from Q2 to Q5.


Attempt any two question from section 2.
Each Question in Section 1 carries 6 marks & Each Question in Section 2 carries 11 marks

Section 1
Answer in 400 words. Each question carry 06 marks.
Q. 1. What do you understand by contiguous and non-contiguous memory allocation. Explain with
the help of diagrams and tables.
Q. 2. What do you understand by I/O systems and I/O interface.
Q.3. What are reusable and consumable resources. What are the various conditions to occur
deadlocks.
Q. 4. Explain any three methods of free space management in disk.
Q.5. Write Short Note on any two. Answer in 300 words. Each carry 03 marks.
a) File system structure.
b) Deadlocks
c) Paging

Section 2

Answer in 800 words. Attempt any 2 [Link] question carry 11 marks


Q6. Explain different methods of disk scheduling with help of diagrams. For example a disk queue
with requests for I/O to blocks on cylinders 95,181,34,119,19,128,61,73 in that order.
Q7. Explain various allocation methods in file systems. Also explain the concept of protection in file
systems.
Q8. Explain FIFO and LRU replacement algorithms with the following reference string
125, B3, 125, 202, 125, 162, 125, B3, 179, B3, B1, 202

150 | P a g e For Internal Circulation


2nd Internal Examination (March 2020)
2018 Course

Course:BCA Semester: III


Subject: Operating Systems Course Code: 301
Max. Marks: 40 Max. Time: 2 Hours

Instructions (if any):- Use of unfair means will lead to cancellation of paper followed by
disciplinary action.
Question No. 1 is compulsory. Attempt any two questions from Q2 to Q5.
Attempt any two question from section 2.
Section 1
Answer in 400 words. Each question carry 06 marks.
Q. 1 Explain static and dynamic relocation.
Q. 2 What do you understand by input output interface?
Q.3 Explain various file access methods.
Q. 4 What do you understand by swapping?
Q.5 Write Short Note on any two. Answer in 300 words. Each carry 03 marks.
a) Internal Fragmentation
b) First fit and next fit
c) File types

Section 2

Answer in 800 words. Attempt any 2 questions. Each question carry 11 marks
Q. 6 What do you understand by deadlocks? Explain deadlock prevention, deadlock avoidance and
deadlock detection & recovery?
Q. 7 Explain interrupt driven I/O and DMA?
Q. 8 Suppose that a disk drive has 50 tracks. The system refers the tracks in following sequence:
25,37,15,9,24,37,39,47,13,25,15
Currently head is on track number 20 and moving outside. Calculate total track movements and time
required to move all these tracks. (Consider seek time = 0.15 ms) in case of:
 Shortest seek time first

151 | P a g e For Internal Circulation


2ndInternal Examination (March 2020)
2014 Course

Course:BCA Semester: III


Subject: Operating Systems Course Code: 301
Max. Marks: 40 Max. Time: 2 Hours

Instructions (if any):- Use of unfair means will lead to cancellation of paper followed by
disciplinary action.
Question No. 1 is compulsory. Attempt any two questions from Q2 to Q5.
Attempt any two question from section 2.
Section 1
Answer in 400 words. Each question carry 06 marks.
Q. 1 Explain static and dynamic relocation.
Q. 2 Write an algorithm to solve producer consumer problem.
Q.3 Explain various file access methods.
Q. 4 What do you understand by Semaphore?
Q.5 Write Short Note on any two. Answer in 300 words. Each carry 03 marks.
a) External Fragmentation
b) Best fit and Worst fit
c) File attributes

Section 2

Answer in 800 words. Attempt any 2 questions. Each question carry 11 marks
Q. 6 What do you understand by directory? Explain different directory structures with the help of
diagram.
Q. 7 Explain interrupt driven I/O and DMA?
Q. 8 Suppose that a disk drive has 50 tracks. The system refers the tracks in following sequence:
25,37,15,9,24,37,39,47,13,25,15
Currently head is on track number 20 and moving outside. Calculate total track movements and time
required to move all these tracks. (Consider seek time = 0.15 ms) in case of:
 First come first serve

152 | P a g e For Internal Circulation


2ndInternal Examination (2019)

Course: BCA Semester: III


Subject: Operating Systems Course Code: 301
Max. Marks: 40 Max. Time: 2 Hours

Instructions (if any):- Use of unfair means will lead to cancellation of paper followed by
disciplinary action.
Question No. 1 is compulsory. Attempt any two questions from Q2 to Q5.
Attempt any two question from section 2.
Section 1
(Theoretical Concept and Practical/Application oriented)
Answer in 400 words. Each question carry 06 marks.
Q. 1 What do you understand by static and dynamic memory allocation?
Q. 2 What are file attributes and file operations?
Q.3 What do you understand by input output interface?
Q. 4 What is segmentation? Explain with the help of diagram.
Q.5 Write Short Note on any two. Answer in 300 words. Each carry 03 marks.
a) External Fragmentation
b) Single level and two level directory
c) Best Fit and Worst Fit

Section 2

Answer in 800 words. Attempt any 2 questions. Each question carry 11 marks
Q6. Suppose that a disk drive has 50 tracks. The system refers the tracks in following sequence:
25,37,15,9,24,37,39,47,13,25,15
Currently head is on track number 20 and moving outside. Calculate total track movements and time
required to move all these tracks. (Consider seek time = 0.15 ms) in case of:
 First come first served
Q7. Explain Programmed I/O and interrupt driven I/O?
Q8. What do you understand by deadlocks? Explain deadlock prevention, deadlock avoidance and
deadlock detection & recovery?

153 | P a g e For Internal Circulation


154 | P a g e For Internal Circulation
Research Papers

155 | P a g e For Internal Circulation


_____________________________________________________________________________________________________
Asian Journal of Research in Computer Science
8(3): 16-31, 2021; Article [Link].68517
ISSN: 2581-8260

A Comprehensive Study of Kernel (Issues and Concepts)


in Different Operating Systems
Hayfaa Subhi Malallah1*, Subhi R. M. Zeebaree1, Rizgar R. Zebari2,
Mohammed A. M.Sadeeq1, Zainab Salih Ageed2, Ibrahim Mahmood Ibrahim1,
Hajar Maseeh Yasin1 and Karwan Jameel Merceedi1
1Duhok Polytechnic University, Duhok, Kurdistan Region, Iraq.
2Nawroz University, Duhok, Kurdistan Region, Iraq.
Authors’ contributions
This work was carried out in collaboration among all authors. All authors read and approved the final
manuscript.
Article Information
DOI: 10.9734/AJRCOS/2021/v8i330201
Editor(s):
(1) Dr. Manish Mahajan, CGC College of Engineering, India.
Reviewers:
(1) Ramjeet Singh Yadav, Ashoka Institute of Technology and Management, India.
(2) Guruprakash CD, Sri Siddhartha Academy of Higher Education, India.
Complete Peer review History: [Link]
Received 01 March 2021
Accepted 08 May 2021
Review Article
Published 08 May 2021
ABSTRACT Various operating systems (OS) with numerous functions and features have
appeared over time. As a result, they know how each OS has been implemented guides users'
decisions on configuring the OS on their machines. Consequently, a comparative study of
different operating systems is needed to provide specifics on the same and variance in novel
types of OS to address their flaws. This paper's center of attention is the visual operating system
based on the OS features and their limitations and strengths by contrasting iOS, Android, Mac,
Windows, and Linux operating systems. Linux, Android, and Windows 10 are more stable, more
compatible, and more reliable operating systems. Linux, Android, and Windows are popular
enough to become user-friendly, unlike other OSs, and make more application programs. The
firewalls in Mac OS X and Windows 10 are built-in. The most popular platforms are Android and
Windows, specifically the novelist versions. It is because they are low-cost, dependable,
compatible, safe, and easy to use. Furthermore, modern developments in issues resulting from
the advent of emerging technology and the growth of the cell phone introduced many features
such as high-speed processors, massive memory, multitasking, high-resolution displays,
functional telecommunication hardware, and so on.

1. INTRODUCTION
The OS is a bunch of specially developed programs running on a computer system that authorizes it to
operate appropriately. The OS is designed to obey two primary purposes: (1) It manages the allotment and
usage of the computer system's resources among the different tasks and users. (2) imparts an interface
between the computing hardware and the developer, making it easier and simplifying it for application
programs to be programmed, generated, and debugged [1].
As OS became more prominent and more complicated, interest in rational segmentation of the program grew.
156 | P a g e OS functions and user support
Comprehensive will Circulation
For Internal be built on top of this skeletal software base. The kernel
provides all else on the machine with critical facilities and defines many of the features of higher applications.
Thus, as a synonym for "kernel," we also use the word "operating system OS." [2].
In a modern general-purpose machine, the operating system kernel has the highest degree of privilege [3].
The kernel governs how scarce resources such as CPU running time and physical memory pages are used by
processes on the device and arbitrates access to protected hardware, as shown in Fig. 1. The kernel is the
component that allows a process on the system to access files, the network, or display configuration data. The
Operating System has two primary functions: it essentially needs to be used as an extension machine. As a
computer system manager, it has to handle and administer all sorts of tools reasonably. Furthermore, specific
systems are responsible for protecting the computing system and offering application-specific services like
networking, graphical interface, etc. [4-6]. Amongst the most challenging aspects of research are security
monitoring and ensuring that no new bugs have been implemented. Until merging with the mainline branch,
kernel developers try to identify as many security problems as possible. Failure to identify vulnerabilities can
result in insecure kernels and systems becoming distributed. Multicore is one of the most critical trends to
improve the efficiency of processors. The current leadership producers are therefore focused on becoming
multicore processors (MCP) [7]. Improvement of the computer capacity multitasking is one of the main benefits
of MCP. These processors provide only a few full-running cores rather than one, each with a separate front-
side bus interface [8, 9].
Fig. 1. The abstract view of a kernel [6]. Malallah et al.; AJRCOS, 8(3): 16-31, 2021; Article
[Link].68517
18

157 | P a g e For Internal Circulation


Different kernel structure designs exist. Monolithic interface between programs and the computing
kernels are running entirely within one address hardware to use hardware such as input, output,
space, cooperating with the CPU operating, and memory allocation [17]. At the same time, the
primarily for speed, in the supervisor mode. As application code is generally run by the hardware
user processes do, microkernels run most of the directly and sometimes calls to or interrupted by
time but not every service is used in the user the operating system function. Many computer-
area, primarily for durability and modularity. containing products – mobile phones and
Service providers are complicated social and consoles for video games, web servers, and
deliberate processes to do something. With supercomputers – have operating systems.
Enterprise, we mean any business company, 1.2 Operating Systems Role on
company, organization, and any formal or Applications and Computations
informal monarch. We mean a social body with a An OS is the machine software that manages
purposeful undertaking [10, 11]. computer hardware and software resources and
The kernel itself offers only basic functionality in allows various applications. These technologies
the microkernel address that enables the can be linked with cloud computing, intelligent
implementation of separate programs and servers device applications, deployment of company
that take former kernel roles, for example, system systems, Web servers' performance, etc. [18, 19].
drivers, GUI servers, etc. The mobile devices with 1.2.1 Cloud computing influence on operating
operating systems, which are among the most systems
common user devices, provide various A cloud is a category of the operating system
communication interfaces between the application designed to work in a cloud computing network
layer software components and hardware devices and virtualization[20]. A cloud operating system
[12]. Today, these devices provide us with a controls the service, execution, and proceedings
significant number of services, such: voice calls, of virtual computers, virtual servers, virtual
messaging, cameras, internet browsers, games, infrastructure, hardware, and software backend
video players, and many others[13]. However, [21]. Several systems are used in cloud
each mobile phone must include some mobile computing technology, and most of them are
operating system to execute these services [14]. implemented and used in particle physics, data
The problem statement of this review research, is retrieval, etc. However, different approaches are
presented through two distinct perspectives: used to improve cloud computing performance.
detailing several concerns related to the types of The word "cloud" is common in some
kernels and merits used and evaluating how organizations but not fully comprehensive and
novel technologies are evaluated, and assessing valuable [22].
underperformance. The primary purpose is to The emphasis in the IT world has now been cloud
study different papers related to kernel issues on computing. It provides individuals and
various types of OS used in different types of organizations with robust computing services
computers/smartphones and provide a brief through the Internet and gives them access to a
review of these studies. pool of standard tools, including storage servers
The rest of the review paper is organized as and applications [23]. Businesses of all sizes are
follows. Section 2 presents types of operating increasingly embracing cloud systems because
systems; in section 3, kernel issues and concept. they get to purchase hardware and software
In section 4 presents some literature reviews, and services at no expense but just pay for each use.
the discussion is summarized in Section 5. This means that they are providing huge
Finally, Section 6 outlines the conclusion. advantages, including cost savings [24]. There
1.1 Operating Systems Controlling of are various levels of cloud architecture in which
Processes Execution and Scheduling each level allows extra user power. In addition, a
The OS software is a device software that decent operating system is essential, and
controls the hardware, software, and services of conventional operating systems cannot fulfill all
the computer program [15]. Timeshare system Malallah et al.; AJRCOS, 8(3): 16-31, 2021;
plans activities to use the system efficiently, Article [Link].68517
which can also involve CPU allocation cost 19
allocation tools, mass storage, printing, and other
services [16]. The operating system serves as an

158 | P a g e For Internal Circulation


cloud requirements. Unique operating systems that can handle cloud requirements also need to be developed
[25, 26]. Cloud computing will recently be described as the latest, commonly scalable method of providing
different applications, services, and data storage [27]. Unfortunately, cloud computing does not have many
systems with secure platforms with all these benefits. Many of these missing cloud computing side tools and
approaches have been used [28].
The Web is this era's most evolving forum. It is a national security condition. During the year 2020,
chain of interconnected Internet hypertext records the proliferation of intelligent (IoT) devices from
containing diverse information in text, pictures, the multiplicity of IoT use technologies was
videos, and other materials. The Internet and projected to rise sharply to 20.4 billion by the end
Web are two different words, sometimes used of the year [40]. With the growing number of
together incorrectly [29, 30]. Internet is an heterogeneous products connected to IoT and
extensive network of linked computers using the data generation, power and bandwidth are
TCP/IP Protocol Suite and the Web, including becoming very difficult for the IoT to allocate to
emails and many other applications, is currently tasks effectively. This view has been designed to
available on the Web [31]. Fast-speed Web integrate cloud computing and IoT [41].
technologies have given access to different 1.2.3 Web servers influences on operating
architectures and have helped move to web systems
hypermedia systems [32]. The idea of cloud An operating system, fast CPU, high memory
computing is evolving very quickly with progress material, specific hardware for particular
in internet technology. Cloud computers allow purposes, running programs, and few Web
users who are located with any device over the pages, etc., are a general webserver [42]. These
Internet to access their data and applications web servers are built with general use computers
through Web browsers [33]. Cloud computing can and use various operating systems like Unix,
contribute to application collaboration and to Linux, Windows, etc. In these implementations,
reducing platform compatibility dependence. The the client accesses the servers via the LAN router
massive changes to cloud infrastructure and web- and the Internet, and the traditional client-server
enabled mobile applications have impacted Configuration is emphasized [26]. The client
conventional business processes[34]. transmits a message to the server to connect to
1.2.2 IoT influences on operating systems the Internet through the router. The Web
The Internet of things, which is undoubtedly the manages the query and links eventually to the
most common technology today, lies behind the desired web server from which the requested
future of communications [35]. IoT data is transmitted to the client. An integrated
implementations range from widespread speech web server is a program and application code
recognition to vital space programmers. Several microcontroller that controls and monitors
attempts have been made to develop IoT systems processes [43]. Web apps' continuous growth has
since the demands of heterogeneous IoT led to a growing demand for resources and
implementations are not met either with standard information through the Internet. We should
Windows/Unix or with modern Real-Time presume that users can reliably and efficiently
operating systems [36]. The Internet of Things access much of their everyday information from
(IoT) enables users to connect trillions and share the Internet [44]. All these resources are website-
intelligent machines and information, tracking and based and server-driven. Web servers then
monitoring resources for home automation accept requests from the website, process, and
systems, related services, healthcare, agriculture, have the [Link], users' dependence on
security surveillance, energy grid, or critical the web-based public and private sectors on
infrastructure management [37]. The dynamic various electronic fields puts tremendous
digitalization of physical components ready to pressure on servers [45]. In addition, the reliability
provide value-added applications for mobile and effectiveness of web servers decide how
devices constantly reduces the boundaries companies and web developers draw their
between artificial and natural environments [38]. customers with accurate and fast responses [46].
The IoT is operated by a specific software that The output of web servers, however, which are
feels, controls, and changes things. This life- instantly influenced by the load. Therefore, it
saving invention would develop into a collection of Malallah et al.; AJRCOS, 8(3): 16-31, 2021;
linked artifacts that permit surgeons to perform Article [Link].68517
remote procedures and persons and to assess 20
their homes and power suppliers [39]. Lead the
facilities in a reasonable manner and a sensitive

159 | P a g e For Internal Circulation


is essential to monitor the load on the web the iPhone, but it expanded to support the Apple
servers [47]. Therefore, researchers need to TV and iPad [34]. Like some other OS, iOS is
design and propose an effective device that can regularly modified from iOS version 4.0, and iOS
withstand a heavy load. version 5.1 is the newest [7]. At the bottom of the
Moreover, the vast and ongoing increase in iPhone operating system architecture, the Main
customer requirements for server resources is the OS layer resides. An extra Pre-occupation layer,
leading cause of the overload. This additional media, cocoa-touch layer, and the core services
burden causes servers to crash and languish layer of the iOS architecture is included. Including
precisely in providing services. Therefore, the scheduler, file system, Mach kernel, memory
overloading server harm hurts the company's system management, and hardware drivers,
consumer appeal, reduces revenues, and loses network and protection framework and inter
credibility [48]. process communication, the OS core layer
2. TYPES OF OPERATING SYSTEMS includes the planner to protect system and
A model of an OS is a large structure that program data [51, 52].
incorporates the many services and 2.4 Macintosh OS
Characteristics offered by the operating system It is much older than Windows OS. A year ago, its
and the tasks it performs [1]. Operating systems Microsoft equivalent was released, and it is the
are mainly classified into the following categories, first-ever popular operating system that is
based on their mechanism structure: graphical-inclined, among other OSs. One of Mac
2.1 Windows OS Interface's Guidelines' key ideas is that everything
This OS was introduced into the market within should remain where it is held. Apps for the Mac
1985, and as a comprehensive and robust kind of operating system are not called massive
software, almost 90% market share above and monoliths. The device's graphic user interface
over other OS. Its perceived and great (GUI) supports the program instructions or
effectiveness as home computers in building commands partially implemented in a hardware-
commercials, manufacturing plants, and its conveyed ROM and partly implemented in
conspicuous presence. At the same time, this distributed libraries, via a reasonably stable event
point is considered not to be so again due to the interface, quickly communicates with Mac OS
overwhelming interest of people in open-source software programs [53].
operating systems [49]. The Microsoft OS as an 2.5 Linux OS
M-S windows family was produced with its origin Linux is a free OS, and that can be downloaded,
from the MS-DOS command line as a graphical updated, and even redistributed at no cost. In the
layer over that of old MS dos, and this is domain of the operating system, Linux is relatively
maintained until date with the DOS Box command new. In the year 1991, it was written and also
prompt that is [Link] [50]. updated for current use. It is possible to compare
2.2 Android OS Linux and Windows to an object whose roof and
Android Inc. is the original developer of this floor are either replaceable or not. However, with
platform. Google eventually acquired it and Linux, as a unit, both roof and floor can be
launched the OS as AOSP. The OHA (Open transferred in whatever way one wishes.
Handset Alliance) creation, a consortium However, the roof and floor of the windows are
responsible for distributing and creating Android, hugely rigid that it stays secure. Developers
complemented this new development. The within the open-source Linux community want to
software that is now published within the Apache gain a significant share of end-user desktops that
license is marked, including a free, open-source increase the number of intended Linux users than
license. As a result of the comprehensive the Unix of old school users who are afraid to
developer communities available that frequently share the desire at OS market and server [54].
update and build applications using custom Malallah et al.; AJRCOS, 8(3): 16-31, 2021;
versions of Java, Android releases a new version Article [Link].68517
[51]. 21
2.3 iPhone OS
An Apple Inc. develops and operates iOS which is
a smartphone OS. It was built and designed for

160 | P a g e For Internal Circulation


3. KERNEL ISSUES
In the beginning, the computer was without multitasking, and darkness was upon the face of the multiuser.
The first computers were single task, single-user 'bare metal' machines. The executing processes had
complete control over the memory, the hardware, and the teletype user interface. The requirement for
multiuser and multitasking necessitated the invention of the (OS). An OS is a set of programs that manage a
computer's resources and provide services efficiently to all application processes. At the heart of an OS is the
kernel. It is the first process loaded at boot time, and it remains in continuous use for the duration of the
session [55]. In its simplest form, a kernel provides the following services:
(1). A 'scheduler' to allocate CPU (Central Processor Unit) resources:
(2). A 'memory manager'.
(3). IPC (Inter-Process Communication) control. In addition, it is may also provide.
(4). Physical device drivers (PDD) abstraction layers for peripheral devices (hardware drivers), and
(5). Logical device drivers (LDD) abstraction layers for disk filing systems called a
Virtual File System (VFS), Protocol Stacks such as Sockets (TCP/IP stack) [56].

All types of OS are being used for all computer machines, including laptops, desktops, supercomputers,
tablets, handhelds, and even video game consoles. In today's ICT world, Apple Inc. designed various
operating systems, Linux by Group, Windows by Microsoft Inc., and Android by Google Inc. and others [57].
3.1 Concepts of Kernels
There are various types of the kernel: Micro-kernel, Monolithic-kernel, and Hybrid Kernel: -
3.1.1 Microkernels
Microkernels have minimal 'built-in' functions, scheduling, memory management, and IPC. All other OS
features are allocated to hardware userland drivers but controlled by the kernel. The advantage of the
microkernel is that the application drivers and window managers are in the user space and can be coded and
quickly substituted in languages not used by the kernel without changing the kernel. A very high IPC
overhead has disadvantages. Examples of microkernels are 'Mach' and 'MINIX' [58].
Fig. 2. The architecture of a Transform of Monolithic Kernel to Microkernel [59]. Malallah et al.;
AJRCOS, 8(3): 16-31, 2021; Article [Link].68517
22

161 | P a g e For Internal Circulation


3.1.2 Monolithic-kernel
It has all the microkernel functionality plus hardware drivers, virtual file system (VFS), and protocol stacks.
This reduces inter-process communication requirements and enhances system security but requires careful
system design and reduces flexibility available to the designer. UNIX and Linux are examples of monolithic
kernels, as illustrated in Fig. 2. [59].
3.1.3 Hybrid-kernels
It attempts to get the best of both worlds by using a mix of micro-kernel and 2/3 monolithic kernel techniques;
for example, windows have a few basic drivers built into the kernel additional drivers in userland.
Unfortunately, some hybrid-kernel designs seem to incorporate the worst of both worlds. Windows and Mac
claim their kernels are hybrid [60].
3.2 Kernel Issues
A comparative analysis of the following OS should be carried out: Windows, Linux, iOS, and Android.
Concern Issues are architectures that support computers, supported file system, type of target computer,
integrated firewall, lay-user friendly, shell terminal, security threat, type of kernel, compatibility, and stability. In
addition, the benefits and drawbacks of each of the operating systems have been identified [61].
4. LITERATURE REVIEW
Different studies on OS used for desktop computer systems and handheld devices have been performed. In
this section, a summary of existing works is provided.
Tian et al. [62] Addressed that the OS kernel is the operating system's central component and plays a vital
role in management of OS resources. The kernel rootkit is a common way to compromise OS kernel (i.e.,
malicious kernel module). When rootkits are loaded into kernel space, they can perform arbitrary high-
privileged malicious operations. In recent years, they concentrated on defeating kernel rootkits by offering
several approaches. However, some restrictions apply to modern methods: 1) most approaches concentrate
on rootkit-detection in user-mode; 2) some tools are only used to find obscure kernel modules; To fix these
issues, VKRD has been proposed, a hardware-assisted virtualization-based kernel rootkit identification
method. VKRD will provide a straightforward and effective execution environment for the target kernel module
to demonstrate its operating time behavior in comparison with previous methods. They used the TF-IDF
approach in order to pick the important run-time functions to train their detection models. Their kernel rootkit
identification solutions have been used theoretically in the cloud world by incorporating the hardware-assisted
virtualization and machine learning techniques. The studies have shown that their machine can detect root
kits for the windows with very high precision and low efficiency.
Kim et al. [63] proposed a Linux-kernel 4.9.108 solution beyond the platform of NVIDIA Jetson AGX Xavier.
Separation of Performance was a highly desirable aspect of the runtime that undertakes the system because
the Xavier series SoC is uniquely designed for embedded deep learning (based) performance-hogging
applications. They suggested a memory-aware equal share scheduling algorithm that could reduce QoS
applications' sensitivity to other co-operation applications' memory-related interference. Its algorithm has
wisely isolated the real stall from the CPU cycles of a running task and compensates for the task that is
memory dependent so that the task gets the desired CPU share until it's too long. In that it does not rely on a
static allocation or division of memory hardware resources, and boosts the efficiency of QoS applications with
just negligence of runtime overhead, the proposed solution was adapative, effective and efficient. In addition,
it was a workaround for software only, that could easily be integrated with a few modifications to the kernel
schedule. You have applied the algorithm in the Linux CFS and named the end product mCFS.
Srinuan et al. [64] COMEX, an OS kernel extension, suggested cooperative memory expansion. COMEX
builds a secure memory pool across nodes in a cluster and improves the OS' memory subsystem by enabling
the Process Page Table to monitor remote memory page frames with no programming effort or changes to
application codes. For low laatency transmitted data with a destination kernel, the COMEX employed Remote
Direct Memory Access (RDMA), which was not based on the old I/O block subsystem architecture, which is
normally used by all documented remote paging. COMEX Malallah et al.; AJRCOS, 8(3): 16-31, 2021; Article
[Link].68517
23

162 | P a g e For Internal Circulation


is well suited to the evolving approach of systems was able to detect slight system disruptions that
architecture of a disintegration of resources that could not be seen by regular I/O or connected
divided hard walls into a new design model for device for the consumer.
different resource pools between server-centered Sun et al. [68] Examined the relationships in the
devices. The modern architecture has allowed the kernel of Android OS through a dynamic network
scaling and scaling-out of the infrastructure and modeling of the operating system. Each node in
removed imbalances in data centres. They their network was a function and connections
deployed and Implemented COMEX on a were different call relationships between them.
networked test-bed platform consisting of 32 Dell Three distinct relationships between topological
servers. Also, performance evaluation findings for statistics and population size have been identified
ten applications within two benchmark suites. The with community research. They also did a
study indicated that COMEX experiences percolation study and identified basic
execution at a higher speed when the ratio of the mechanisms in software networks in order to
footprint size of the device execution to the local locate organizational vulnerabilities on a different
memory size increases, with speed rising to 170 scale. Its results may help to clarify the
when the ratio is equal to 10. complexities of the system and to devise
Duca et al. [65] Presented real-time open- appropriate methods of software testing.
sourcing driver implementation for Texas Iqbal et al. [69] Google has built a simple Linux
Instruments OMAP4 multicanal SPI peripheral on kernel designed to operate on touch-screen
EVL, PREEMPT RT and Xenomai real-time Linux platform such as tablets and smartphones with
extensions. Furthermore, the device was the Android mobile operating system. As a result
equipped with an FPGA-based interrupt and SPI of poor OS protections, numerous security
latency evaluation system which tests the drivers attacks have made it vulnerable to restricting the
in real time. One million test samples were access of third-party applications from sensitive
generated for each SPI real-time driver in the infrastructure. They proposed the optimal
testing and the implementation was tested in real permission elimination solution. Also
time. For both experiments, both latencies and demonstrated a way to avoid exploiting
the transition time of SPI are limited to available application authorization by holding availability on
values. Which means that all four SPI shared User of ID set applications. Proposed
implementations have real time behaviour. The Security is derived through the tool as a solution
results are acceptable. PREEMPT RT has the and how to prevent the breach of user information
lowest power output of all four implementations, to ensure Security—different types of Android
but satisfies real-time restrictions, and has protection threats and different permission types
considered that the non-real-time regular Linux for Android applications.
OMAP4 mcSPI driver with stress tested latencies Wang et al. [70] Addressing Android kernel
of several milliseconds. By PREEMPT RT-EVL, activity extensively, a kernel based CrowdNet
the PREEMPT RT output has been enhanced. architecture for cloud computing platforms was
Then EVL came, and Xenomai achieved the best first introduced. CrowdNet. CrowdNet also
result. included an automated data provider which
Boggavarapu et al. [66] Proposed Dual-Dedup, a collects kernel footprints and a parallel malware
lightweight scheme that brought lower layer block forecast that validates malicious activity on
deduplication to the knowledge of page cache Malallah et al.; AJRCOS, 8(3): 16-31, 2021;
management. The redundancy information Article [Link].68517
sensed by the block-level deduplication layer was 24
revealed to the cache page, thus removing cache
redundancy and preventing unwanted read
requests. On the Linux EXT4 they developed a
device prototype. Results of experiments showed
that double-degrees would increase reading
efficiency dramatically. As an example, Dual-
Dedup enhanced read performance 34 percent
by using FIO benchmarks for a data collection of
25 percent duplicate data.
Liu et al. [67] Submitted a principle evidence for
the new technique for ESD-induced soft failure
identification by evaluating the operating system
kernel feature trace records. The tool was used to
monitor Linux function calls during regular service
and after the injection of ESD tension. In order to
163 | Pchanges
illustrate age For Internal Circulation
caused by ESD, the records
were displayed in graphical feature maps and
machine call distribution for each operation. The
experimental results showed that the
improvements in the feature maps and the call
distribution within the observed procedures
showed that the soft failures. The new approach
Android. Then, using a heuristic approach to 12,750 Android apps, they measured and picked hidden centers to
minimize iteration and the time complexity. Their experimental findings indicate that CrowdNet protected large-scale
data validation and doubled kernel learning. Increased classification performance by detecting malicious attacks with
CrowdNet, comparison with conventional neural networks and other machine learning techniques.
Kouki et al. [71] The topic of mutual data monitoring under the imperfect of wireless networking has been examined in
a class of multi-agent linear systems. A prediction control program for the autonomous Internet of Things was
developed to drive a single-wheel robot. A new approach was developed using the STM 32-running Revolutionary
Internet of Things Operating System and RFCs through the User Datagram Protocol. Due to the large number of
packet errors in communication channels, for the performance assessment of the predictive control algorithm the
User Datagram Protocol was used. A robust study of agent Internet of Things technologies and a network predictive
packet failure management technique, restricted bandwidth and attachment connections have been undertaken. It
was mostly that the management and stability of closed loop control systems could be achieved by consensus.
Several experimental scenarios showed the reliability of the proposed concept solution.
Saleel et al. [72] studied the vulnerability in the Linux kernel called dirty copy on write. They indicated that the
mentioned vulnerability is a serious issue, and unauthenticated users could complete controlling the devices operated
by Linux OS. The authors have shown that the attacker could use the existing vulnerability and perform numerous
different attacks. Also, they indicated that this issue could be addressed by using antivirus. Moreover, they revealed
that all Linux distributions (Red Hat. Debian. Ubuntu. SUSE) had fixed this problem by updating the OS. Further,
deep defense, up-to-date OS, and proper firewall should be used to tackle this issue on Linux OS.
Cha et al. [73] presented an analysis study related to the kernel of the Linux operating system on multicore systems
that can process packets. Moreover, they identified the major performance bottlenecks in the Linux kernel network
stack's packet processing direction and provided insight into various performance and scalability issues that must be
addressed. The proposed study focused on the software-defined network functions running in the kernel space due to
these user-space application-related overheads. They indicated that the performance of the Linux kernel could be
enhanced by preventing program stack contention. In addition, the results have shown that beyond a particular stage,
the output does not scale uniformly as the number of cores increases. NUMA locality, process synchronization
overheads, interrupt management, buffer bloating, direct memory access overhead, as well as using CPU cycles and
NIC capacity are all possible considerations.
Jung et al. [74] demonstrated how to port AODV-UU from an older kernel to a newer one. By introducing threads and
direct access to the routing table. Moreover, they eliminated the need for a particular kernel by eliminating the kernel
dependency. In a simple example, the authors test the operation of the implemented AODV-UU. In more details,
instead of using libipq, they used a direct queue. In that architecture, the routing table was operated directly by a new
AODV thread, while in previous versions, it was controlled by the kaodv module.
5. SURVEY DISCUSSION AND ANALYSIS
This review presents five operating system types (Windows, Mac, Linux, iOS, and Android) operating systems based
on the operating system characteristics with their weaknesses and strengths. The research paper aims to show core
concepts of the primary desktop and handheld OS and preview the comparisons between them and include and
review user interface toolkits from a technological developers' standpoint. The similarity of operating systems based
on issues and characteristics is illustrated in Table1.
As shown in Table 1, it concerns the issues and merits of the various operating system used in different types of
computer/mobile devices. Most kernels that were widely studied in the five previous years are Linux and Android
kernels, respectively. Most of the studies performed on the central issue are the security concerns such as malware,
attack intrusion detection, and prevention, etc. Moreover, the researchers used numerous tools and frameworks to
carry out their studies. The target of their research was to improve the performance of the different kernels in several
fields. Malallah et al.; AJRCOS, 8(3): 16-31, 2021; Article [Link].68517
25

Table 1. Kernel Type OS Tools Issues Merits


Critical Type
analysis of
existing
studies Ref.
[62] Kernel Windows OS. Kernel rootkit Allow hackers With both
Module. detection the ability to extreme
virtualization circumvent, accuracy and
method based disable moderate cost
on machine antivirus of

164 | P a g e For Internal Circulation


learning and software, and performance,
the TF-IDF monitor your the device can
technique. keyword keys detect
to make it Windows
easy to steal kernel
your private rootkits.
information
from
criminals.
[63] XNU Linux Embedded Five SPEC Many H\W are Adaptive,
kernel patch. OS. CPU2017 based on efficient, and
simulation solutions, responsive
programs inefficient since it does
were used, as reference not focus on
well as the management, any static
YOLO or partitioning or
detection of unsuccessful allocation of
face software. throttling H\W memory
execution, references
making it and enhances
impossible to QoS network
use a COTS performance.
and SoC
platform is
widely
distributed
operating
systems such
as Linux.
[64] COMEX on Windows and COMEX has To allow fine- Enabling
Linux kernel Linux OS. been grain kernel- software with
3.10.87. implemented level memory memory
on the Linux aggregation in footprints
kernel and computed better than
installed on its network what is
32 networked systems to required for
servers. support the the physical
design of memory of a
reference node alone,
segmentation COMEX uses
and swapping remote node
of page physical
defects memory in a
through the networked
virtual distributed
memory system.
subsystem of
the Linux OS.
[65] Linux kernel Real-time OS Real-time The author PREEMPT
open source open-source proposed real RT-EVL
drivers for the (time) actions develops the
Texas real- in the relating performance
time Linux drivers of of PREEMPT
versions of Linux for the RT. Then
EVL, Xilinx OMAP4 arrives
PREEMPT more than one Xenomai and
RT, and channel SPI EVL obtain
Xenomai chip and the correct
Instruments implemented results.
OMAP4 multi- and designed
channel SPI an
165 | P a g e For Internal Circulation
peripheral. assessment
method.

[66] Linux Kernel. Real-time OS. Implement the Big data In terms of
Dual-De-dup performance both read
module in the with performance
Virtual File eliminating and
System (VFS) unwanted disk throughput, it
layer. reads in the illustrates
page cache significant
on duplicate new features.
data.
[67] Linux Kernel GNU/Linux It is using Temporary This novel
function call. OS. kernel call- upsets-soft method can
trace faults can be detect subtle
recordings caused by device upsets
using a high- electrostatic that are not
speed router discharge detectable by
operating on (ESD) into a normal I/O or
Linux. A test working attached
port that device. Subtle devices to the
soft failures user.
can reduce
system
stability and
cannot be
defined by

166 | P a g e For Internal Circulation

You might also like