OS Course Pack
OS Course Pack
*********
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.
12 MCQ
112
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
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.
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]
Evaluation
Internals: 40%
Externals: 60%
Total : 100%
Attendance Policy
Session Plan:
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.
Reliability problem
One must have to take care of security and integrity of user programs and data
Data communication problem
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
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.
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.
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.
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.
There are several types of Operating Systems which are mentioned below.
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
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
There is not any facility for user interaction of system resources with the 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.
Due to the multiple CPU, it can be more complex and somehow difficult to understand.
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
Time-Sharing OS
Advantages of Time-Sharing OS
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.
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.
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.
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.
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.
Examples of Network Operating Systems are Microsoft Windows Server 2003, Microsoft Windows
Server 2008, UNIX, Linux, Mac OS X, Novell NetWare, BSD, etc.
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.
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.
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
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.
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
.
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 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
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.
2. Multiprocessing –
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.
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.
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.
• MONOLYTHIC STRUCTURE
• SIMPLE STRUCTURE
• LAYERED STRUCTURE
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.
Process concept
Process Control Block
process states and its transitions
context switch
OS services for Process management
scheduling and types of schedulers
scheduling algorithm
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).
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 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.
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.
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.
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.
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
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.
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:
After the process finishes its tasks, the operating system ends it and removes its Process Control Block
(PCB).
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 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.
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.
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
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.
4. Waiting Time
A scheduling algorithm does not affect the time required to complete the process once it starts execution.
It only affects the waiting time of a process i.e. time spent by a process waiting in the ready queue.
5. Response Time
In an interactive system, turn-around time is not the best 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
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.
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.
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).
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.
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.
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.
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
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
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
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
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
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
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
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
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
At time = 15,
Process P5 will finish its execution.
Remaining
Time Arrival Waiting Execution Initial Burst Burst
Instance Process Time Table Time Time Time
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
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.
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.
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.
Q.1: Which of the following need not necessarily be saved on a context switch between processes?
(GATE-CS-2000)
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.
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.
Operations on Processes
A process is an activity of executing a program. Basically, it is a program under execution. Every process
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:
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.
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.
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.
#define buff_max 25
#define mod %
struct item{
item nextProduced;
while(1){
shared_buff[free_index] = nextProduced;
free_index = (free_index + 1) mod buff_max;
}
item nextConsumed;
while(1){
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.
#define buff_max 25
#define mod %
struct item {
// different member of the produced data
// or consumed data
// ---------
};
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);
return 0;
}
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.
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 :
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.
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:
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.
Disadvantages of IPC:
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
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 –
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.
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.
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.
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.
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 −
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.
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.
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.
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.
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.
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.
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.
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 −
P0 0-0=0
P1 5-1=4
P2 8-2=6
P0 0 5 0
P1 1 3 5
P2 2 8 14
P3 3 6 8
P0 0-0=0
P1 5-1=4
P2 14 - 2 = 12
P0 0 5 1 0
P1 1 3 2 11
P2 2 8 1 14
P3 3 6 3 5
P0 0-0=0
P1 11 - 1 = 10
P2 14 - 2 = 12
P0 (0 - 0) + (12 - 3) = 9
P1 (3 - 1) = 2
Mutual Exclusion
Semaphore
Busy-wait Implementation
characteristics of semaphore
queuing implementation of semaphore
producer consumer problem
Critical region and conditional critical area.
Deadlock
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.
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.
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.
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.
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.
Initialization of semaphores
mutex = 1
Full = 0 // Initially, all slots are empty. Thus full slots are 0
Empty = n // All slots are empty initially
//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.
wait(full);
wait(mutex);
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.
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.
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
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.
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);
} while(true);
Reader Process
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.
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.
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.
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.
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.
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.
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.
Example:
Total resources in system:
ABCD
6576
The total number of resources are
Available system resources are:
ABCD
3112
Available resources are
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 files contain list of file names and other information related to these files.
Special 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
Contiguous Allocation
Linked Allocation
Indexed Allocation
Contiguous Allocation
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.
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.
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.
Step Description
5 DMA controller transfers bytes to buffer, increases the memory address, decreases the
counter C until C becomes zero.
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.
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
Example:
Suppose the order of request is- (82,170,43,140,24,16,190)
And current position of Read/Write head is : 50
Example:
=(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:
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”.
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”
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.
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.
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.
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?
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
Answer: (a) the total number of blocks that have been used for the index, size of all the blocks
3. Out of these page replacement algorithms, which one suffers from Belady’s anomaly?
a. LRU
b. FIFO
Answer: (b)FIFO
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?
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
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
c. 13 bits
d. 11 bits
a. The processes on the system access pages and not memory frequently
Answer: (a) The processes on the system access pages and not memory frequently
c. An exception is thrown
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
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
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
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
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:
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
a. 124
b. 122
c. 120
d. 118
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:
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?
b. The existing programs do not need to be re-linked so as to take advantage of the newer library
versions
21. Out of all the following, which one isn’t a form of memory?
c. instruction register
d. instruction cache
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
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.
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
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
27. Which of these disk scheduling policies results in minimum head movement?
a. Circular scan
b. Elevator
c. FCS
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:
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.
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:
Answer: (c) a poorer disk space utilisation but better disk throughput
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?
Answer: (b) A resolution of 1600 x 400 and a 14-inch monitor with 16 million colours.
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
P. The shortest remaining time in the first 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:
P1 : 0 20
P2 : 15 25
P3 : 30 10
P4 : 45 15
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
39. Out of the following, which one is FALSE about Shortest Job First Scheduling (SJF)?
a. Only X1
b. Only X2
c. Neither X2 nor X1
d. Both X2 and X1
fork();
fork();
fork();
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
a. The Operating System maintains only the CPU register state on a per-thread basis
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.
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.
a. Power failure
b. Scheduler process
c. Timer
d. A device
b. General-purpose registers
c. Program counter
46. In the case of a working-set strategy, which of these is done by the OS to prevent thrashing?
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
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:
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:
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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)
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
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?
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.
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
Instructions (if any):- (accounting, mathematics regarding use of Calculator, if required). Give
Examples & Diagrammatic Representations wherever as possible
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
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
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
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?
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
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
[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