OS Interview Questions
OS Interview Questions
OS Interview Questions
Answer:
OS is the most essential and vital part of a computer without which it is considered
useless. It enables an interface or acts like a link for interaction between computer
software that is installed on OS and users. It also helps to communicate with hardware
and also maintains balance among hardware and CPU. It also provides services to users
and a platform for programs to run on. It performs all common tasks applications require.
Q2. What's the main purpose of an OS? What are the di erent types of OS?
Answer:
The main purpose of an OS is to execute user programs and make it easier for users to
understand and interact with computers as well as run applications. It is specially
designed to ensure that the computer system performs better by managing all
computational activities. It also manages computer memory, processes, and operation of
all hardware and software.
Types of OS:
• Batched OS (Example: Payroll System, Transactions Process, etc.)
• Multi-Programmed OS (Example: Windows O/S, UNIX O/S, etc.)
• Timesharing OS (Example: Multics, etc.)
• Distributed OS (LOCUS, etc.)
• Real-Time OS (PSOS, VRTX, etc.)
Answer:
• Such systems are used widely nowadays to improve performance in systems that
are running multiple programs concurrently.
• By increasing the number of processors, a greater number of tasks can be
completed in unit time.
• One also gets a considerable increase in throughput and is cost-e ective also as all
processors share the same resources.
• It simply improves the reliability of the computer system.
Answer:
RAID (Redundant Arrays of Independent Disks) is a method used to store data on Multiple
hard disks therefore it is considered as data storage virtualization technology that
combines multiple hard disks. It simply balances data protection, system performance,
storage space, etc. It is used to improve the overall performance and reliability of data
storage. It also increases the storage capacity of the system and its main purpose is to
achieve data redundancy to reduce data loss
Answer:
The pipe is generally a connection among two or more processes that are interrelated to
each other. It is a mechanism that is used for inter-process communication using
message passing. One can easily send information such as the output of one program
process to another program process using a pipe. It can be used when two processes
want to communicate one-way i.e., inter-process communication (IPC).
Q7. What are the di erent kinds of operations that are possible on semaphore?
Answer:
There are basically two atomic operations that are possible:
• Wait()
• Signal()
Answer:
It is generally a program that initializes OS during startup i.e., rst code that is executed
whenever computer system startups. OS is loaded through a bootstrapping process or
program commonly known as booting. Overall OS only depends on the bootstrap
program to perform and work correctly. It is fully stored in boot blocks at a xed location
on the disk. It also locates the kernel and loads it into the main memory after which the
program starts its execution.
Answer:
Demand paging is a method that loads pages into memory on demand. This method is
mostly used in virtual memory. In this, a page is only brought into memory when a
location on that particular page is referenced during execution.
Answer:
Real Time Operating System (RTOS) is an operating system that is used for real-time
applications i.e., for those applications where data processing should be done in a xed
ffi
ff
fi
fi
fi
and small measure of time. It performs much better on tasks that are needed to be
executed within a short time. It also takes care of execution, monitoring, and all-
controlling processes. It also occupies less memory and consumes fewer
resources. RTOS is used in Air tra c control systems, Anti-lock Brake Systems, and
Heart pacemakers.
Answer:
Process synchronization is basically a way to coordinate processes that use shared
resources or data. It is very much essential to ensure synchronized execution of
cooperating processes so that will maintain data consistency. Its main purpose is to share
resources without any interference using mutual exclusion.
Answer:
Di erent IPC(Interprocess Communication) Mechanisms:
• Pipes
• Message Queuing
• Semaphores
• Socket
• Shared Memory
• Signals
Answer:
Primary Secondary
Memory Memory
Data can be Firstly, data is
directly transferred to
accessed by the primary memory
processing unit. and after then
routed to the
processing unit.
It can be both It is non-volatile
volatile and in nature.
non-volatile in
nature.
It is more costly It is more cost-
than secondary e ective or less
memory. costly than
primary
memory.
It is temporary It is permanent
because data is because data is
stored stored
temporarily. permanently.
ff
ff
ff
ff
ffi
In this memory, In this memory,
data can be lost data is stored
whenever there permanently
is a power and therefore
failure. cannot be lost
even in case of
power failure.
It is much faster It is slower as
than secondary compared to
memory and primary memory
saves data that and saves
is currently used di erent kinds
by the of data in
computer. di erent
formats.
It can be It can be
accessed by accessed by I/O
data. channels.
Answer:
Overlays is a programming method that divides processes into pieces so that instructions
that are important and need can be saved in memory. It does not need any type of
support from the OS. It can run programs that are bigger in size than physical memory by
only keeping only important data and instructions that can be needed at any given time.
Answer:
Some of the top OS’s that are used mostly are given below:
• MS-Windows
• Ubuntu
• Mac OS
• Fedora
• Solaris
• Free BSD
• Chrome OS
• CentOS
• Debian
• Android
Answer:
It is a memory management technique feature of OS that creates the illusion to users of a
very large (main) memory. It is simply space where a greater number of programs can be
stored by themselves in the form of pages. It enables us to increase the use of physical
memory by using a disk and also allows us to have memory protection. It can be
ff
ff
managed in two common ways by OS i.e., paging and segmentation. It acts as temporary
storage that can be used along with RAM for computer processes.
Answer:
Thread is a path of execution that is composed of a program counter, thread id, stack,
and set of registers within the process. It is a basic unit of CPU utilization that makes
communication more e ective and e cient, enables utilization of multiprocessor
architectures to a greater scale and greater e ciency, and reduces the time required in
context switching. It simply provides a way to improve and increase the performance of
applications through parallelism.
Threads are sometimes called lightweight processes because they have their own stack
but can access shared data.
Answer:
The process is basically a program that is currently under execution. The main function of
an OS is to manage and handle all of these processes. When a program is loaded into the
memory and it becomes a process, it can be divided into four sections ─ stack, heap,
text, and data.
Answer:
• New State: In this state, a process is just created.
• Running: In this state, the CPU starts working on the process’s instructions.
• Waiting: In this state, the process cannot run because it just waits for some event
to occur
• Ready: In this state, the process has all resources available that are required to run
but it waits to get assigned to a processor because CPUs are not working currently
on instructions passed by the process.
• Terminate: In this state, the process is completed I.e., the process has nished
execution.
Answer:
FCFS (First Come First Serve) is a type of OS scheduling algorithm that executes
processes in the same order in which processes arrive. In simple words, the process that
arrives rst will be executed rst. It is non-preemptive in nature. FCFS scheduling may
cause the problem of starvation if the burst time of the rst process is the longest among
all the jobs. Burst time here means the time that is required in milliseconds by the process
for its execution. It is also considered the easiest and simplest OS scheduling algorithm
as compared to others. Implementation of FCFS is generally managed with help of the
FIFO (First In First Out) queue.
fi
ff
ff
fi
ffi
ffi
fi
fi
Q21. What is Reentrancy?
Answer:
Reentrant is simply a function in which various clients can use and shares a single copy
of a program during a similar period. This concept is generally associated with OS code
and does not deal with concurrency. It has two major functions:
• Program code cannot change or modify itself.
• Local data for every client process needs to be stored in di erent disks.
Answer:
A scheduling algorithm is a process that is used to improve e ciency by utilizing
maximum CPU and providing minimum waiting time to tasks. It simply deals with the
problem of deciding which of outstanding requests is to be allocated resources. Its main
aim is to reduce resource starvation and to ensure fairness amongst parties that are
utilizing the resources. In simple words, it is used to allocate resources among various
competing tasks.
Answer:
Paging Segmentation
It is invisible to a It is visible to a
programmer. programmer.
In this, the size In this, the size
of pages is of segments is
xed. not xed.
Procedures and Procedures and
data cannot be data can be
separated in separated in
paging. segmentation.
It allows a It allows all
cumulative total programs, data,
of virtual and codes to
address spaces break up into
to cross independent
physical main address spaces.
memory.
It is mostly It is mostly
available on available on
CPUs and MMU Windows
chips. servers that may
support
backward
compatibility,
while Linux has
limited support.
fi
fi
ff
ff
ffi
It is faster for It is slower as
memory access compared to
as compared to paging.
segmentation.
In this, OS In this, OS
needs to needs to
maintain a free maintain a list of
frame. holes in the
main memory.
In paging, the In
type of segmentation,
fragmentation is the type of
internal. fragmentation is
external.
The size of the The size of the
page is page is
determined by determined by
available the user.
memory.
Answer:
Paging: It is generally a memory management technique that allows OS to retrieve
processes from secondary storage into main memory. It is a non-contiguous allocation
technique that divides each process in the form of pages.
Segmentation: It is generally a memory management technique that divides processes
into modules and parts of di erent sizes. These parts and modules are known as
segments that can be allocated to process.
Answer:
It is generally a situation where the CPU performs less productive work and more
swapping or paging work. It spends more time swapping or paging activities rather than
its execution. By evaluating the level of CPU utilization, a system can detect thrashing. It
occurs when the process does not have enough pages due to which the page-fault rate is
increased. It inhibits much application-level processing that causes computer
performance to degrade or collapse.
Answer:
It refers to the ability to execute or perform more than one program on a single processor
machine. This technique was introduced to overcome the problem of underutilization of
CPU and main memory. In simple words, it is the coordination of execution of various
programs simultaneously on a single processor (CPU). The main objective of
ff
multiprogramming is to have at least some processes running at all times. It simply
improves the utilization of the CPU as it organizes many jobs where the CPU always has
one to execute.
Answer:
Asymmetric Clustering is generally a system in which one of the nodes among all nodes is
in hot standby mode whereas the rest of all nodes run di erent applications. It simply
uses whole or entire hardware resources therefore it is considered a more reliable system
as compared to others.
Answer:
Multitasking Multiprocessin
g
It performs It performs
more than one more than one
task at a time task at a time
using a single using multiple
processor. processors.
In this, the In this, the
number of number of
CPUs is only CPUs is more
one. than one.
It is more It is less
economical. economical.
It is less e cient It is more
than e cient than
multiprocessing. multitasking.
It allows fast It allows smooth
switching processing of
among various multiple tasks at
tasks. once.
It requires more It requires less
time to execute time for job
tasks as processing as
compared to compared to
multiprocessing. multitasking.
Answer:
The socket in OS is generally referred to as an endpoint for IPC (Interprocess
Communication). Here, the endpoint is referred to as a combination of an IP address and
port number. Sockets are used to make it easy for software developers to create
network-enabled programs. It also allows communication or exchange of information
ffi
ffi
ff
ff
between two di erent processes on the same or di erent machines. It is mostly used in
client-server-based systems.
Answer:
There are basically four types of sockets as given below:
• Stream Sockets
• Datagram Sockets
• Sequenced Packet Sockets
• Raw Sockets
Answer;
Zombie process, referred to as a defunct process, is basically a process that is
terminated or completed but the whole process control block is not cleaned up from the
main memory because it still has an entry in the process table to report to its parent
process. It does not consume any of the resources and is dead, but it still exists. It also
shows that resources are held by process and are not free.
Answer:
Cascading termination is a process termination in which if the parent process is exiting or
terminating then the children process will also get terminated. It does not allow the child
to continue processing as its parent process terminates. It is generally initiated by OS.
Answer:
Starvation: It is generally a problem that usually occurs when a process has not been
able to get the required resources it needs for progress with its execution for a long
period of time. In this condition, low priority processes get blocked and only high priority
processes proceed towards completion because of which low priority processes su er
from lack of resources.
Answer:
ff
ff
ff
ff
Semaphore is a signaling mechanism. It only holds one positive integer value. It is simply
used to solve the problem or issue of critical sections in the synchronization process by
using two atomic operations i.e., wait() and signal().
Answer:
The kernel is basically a computer program usually considered as a central component or
module of OS. It is responsible for handling, managing, and controlling all operations of
computer systems and hardware. Whenever the system starts, the kernel is loaded rst
and remains in the main memory. It also acts as an interface between user applications
and hardware.
Functions of Kernel:
• It is responsible for managing all computer resources such as CPU, memory, les,
processes, etc.
• It facilitates or initiates the interaction between components of hardware and
software.
• It manages RAM memory so that all running processes and programs can work
e ectively and e ciently.
• It also controls and manages all primary tasks of the OS as well as manages
access and use of various peripherals connected to the computer.
• It schedules the work done by the CPU so that the work of each user is executed
as e ciently as possible.
Answer:
There are basically ve types of Kernels as given below:
• Monolithic Kernel
• MicroKernel
• Hybrid Kernel
• Nano Kernel
• Exo Kernel
Answer:
MicroKernel: It is a minimal OS that executes only important functions of OS. It only
contains a near-minimum number of features and functions that are required to implement
OS.
Example: QNX, Mac OS X, K42, etc.
Answer:
It is a system that allows more than one user to access the resources of a particular
system in many locations. In simple words, it performs multiple tasks on a single
processor or CPU. As the name suggests, it means to share time into multiple slots in
several processes. It also allows di erent users from di erent locations to use a particular
computer system at the same time therefore it is considered one of the important types of
OS.
Answer:
Context switching is basically a process of saving the context of one process and loading
the context of another process. It is one of the cost-e ective and time-saving measures
executed by CPU the because it allows multiple processes to share a single CPU.
Therefore, it is considered an important part of a modern OS. This technique is used by
OS to switch a process from one state to another i.e., from running state to ready state. It
also allows a single CPU to handle and control various di erent processes or threads
without even the need for additional resources.
Answer:
Kernel OS
It is considered It is considered
a central system
component of software.
OS
It is generally It is generally
responsible for responsible for
converting user managing the
commands into resources of
machine-level system.
commands.
It simply acts as It simply acts as
an interface an interface
between between
hardware and hardware and
applications. user.
ff
ff
ff
ff
ff
It also performs It also performs
functions like functions like
process providing
management, security to data
le and les in the
management, the system,
device providing
management, I/ access controls
O to users,
communication, maintaining the
etc. system privacy,
etc.
Its type includes Its type includes
Microkernel, Single and
Monolithic Multiprogrammi
kernel, etc. ng batch
systems,
Distributed OS,
Real-time OS.
Answer:
Process Thread
It is a computer It is the
program that is component or
under entity of the
execution. process that is
the smallest
execution unit.
These are These are
heavy-weight lightweight
operators. operators.
It has its own It uses the
memory space. memory of the
process they
belong to.
It is more It is easier to
di cult to create a thread
create a as compared to
process as creating a
compared to process.
creating a
thread.
It requires more It requires fewer
resources as resources as
compared to compared to
thread. processes.
fi
ffi
fi
ff
It takes more It takes less
time to create time to create
and terminate a and terminate a
process as thread as
compared to a compared to a
thread. process.
It usually run-in It usually run-in
separate shared memory
memory space. space.
It does not It shares data
share data. with each other.
It can be It can’t be
divided into further
multiple subdivided.
threads.
Answer:
There are basically four sections in the process as given below:
• Stack: It is used for local variables and returns addresses.
• Heap: It is used for dynamic memory allocation.
• Data: It stores global and static variables.
• Code or text: It comprises compiled program code.
Answer:
Deadlock is a situation where a set of processes are blocked as each process is holding
resources and waits to acquire resources held by another process. In this situation, two or
more processes simply try to execute simultaneously and wait for each to nish their
execution because they are dependent on each other. We can see a hand problem in our
system whenever a deadlock occurs in a program. It is one of the common problems you
can see in multiprocessing.
Answer:
There are four necessary conditions for deadlock as given below:
• Mutual Exclusion
• Hold and Wait
• No Pre-emption
• Circular Wait or Resource Wait
Answer:
fi
In the Operating System, process data is loaded in xed-sized chunks and each chunk is
referred to as a page. The processor loads these pages in the xed-sized chunks of
memory called frames. Belady’s Anomaly is a phenomenon in which if we increase the
number of frames in memory, then the number of page faults also increases. It is
generally experienced when we use FIFO (First in First out) page replacement algorithm.
Answer:
Spooling simply stands for Simultaneous peripheral operations online. It is referred to as
putting data of various I/O jobs in a bu er. Here, bu er means a special area in memory
or hard disk that can be accessible to an I/O device. It is used for mediation between a
computer application and a slow peripheral. It is very useful and important because
devices access or acquire data at di erent rates. This operation also uses disk as a very
large bu er and is capable of overlapping I/O operations for one task with processor
operations for another task.
Answer:
Process is a program that is currently under execution by one or more threads. It is a
very important part of the modern-day OS.
Answer:
Thread is a path of execution that is composed of the program counter, thread id, stack,
and set of registers within the process.
Answer:
Kernel is a system program that controls all programs running on the computer. The
kernel is basically a bridge between the software and hardware of the system.
Answer:
Deadlock. If a thread that had already locked a mutex, tries to lock the mutex again, it will
enter into the waiting list of that mutex, which results in a deadlock. It is because no other
thread can unlock the mutex. An operating system implementer can exercise care in
identifying the owner of the mutex and return it if it is already locked by the same thread
to prevent deadlocks.
Answer:
First-Come, First-Served (FCFS) Scheduling.
Shortest-Job-Next (SJN) Scheduling.
ff
ff
ff
ff
ff
fi
fi
Priority Scheduling.
Shortest Remaining Time.
Round Robin(RR) Scheduling.
Multiple-Level Queues Scheduling.
Answer:
Time-sharing is a logical extension of multiprogramming. The CPU performs many tasks
by switches that are so frequent that the user can interact with each program while it is
running. A time-shared operating system allows multiple users to share computers
simultaneously.
Answer:
The banker’s algorithm is a resource allocation and deadlock avoidance algorithm that
tests for safety by simulating the allocation for predetermined maximum possible
amounts of all resources, then makes an “s-state” check to test for possible activities,
before deciding whether allocation should be allowed to continue.
Q55. State the main di erence between logical and physical address space?
Answer:
LOGICAL PHYSICAL
ADDRESS ADDRESS
Basic generated by location in a
CPU. memory unit.
Address Space Logical Address Physical
Space is a set Address is a set
of all logical of all physical
addresses addresses
generated by mapped to the
the CPU in corresponding
reference to a logical
program. addresses.
Visibility Users can view Users can never
the logical view the
address of a physical
program. address of the
program.
Generation generated by Computed by
the CPU. MMU.
ff
Access The user can The user can
use the logical indirectly
address to access physical
access the address but not
physical directly.
address.
Q56. How does dynamic loading aid in better memory space utilization?
ANSWER:
With dynamic loading, a routine is not loaded until it is called. This method is especially
useful when large amounts of code are needed in order to handle infrequently occurring
cases such as error routines.
ANSWER:
Processes are stored and remove from memory, which makes free memory space, which
is too little to even consider utilizing by di erent processes. Suppose, that process is not
ready to dispense to memory blocks since its little size and memory hinder consistently
stay unused is called fragmentation. This kind of issue occurs during a dynamic memory
allotment framework when free blocks are small, so it can’t satisfy any request.
ANSWER:
Paging is a method or technique which is used for non-contiguous memory allocation. It
is a xed-size partitioning theme (scheme). In paging, both main memory and secondary
memory are divided into equal xed-size partitions. The partitions of the secondary
memory area unit and the main memory area unit are known as pages and frames
respectively.
Paging is a memory management method accustomed fetch processes from the
secondary memory into the main memory in the form of pages. in paging, each process is
split into parts wherever the size of every part is the same as the page size. The size of
the last half could also be but the page size. The pages of the process area unit hold on
within the frames of main memory relying upon their accessibility
ANSWER:
Swapping is a simple memory/process management technique used by the operating
system(os) to increase the utilization of the processor by moving some blocked processes
from the main memory to the secondary memory thus forming a queue of the temporarily
suspended processes and the execution continues with the newly arrived process. During
regular intervals that are set by the operating system, processes can be copied from the
main memory to a backing store, and then copied back later. Swapping allows more
processes to be run that can t into memory at one time
fi
fi
fi
ff
Q60. Write a name of classic synchronization problems?
ANSWER:
• Bounded-bu er
• Readers-writers
• Dining philosophers
• Sleeping barber
————————————————————————
TEST YOURSELF
Q4. Which of the following programs runs just after booting the computer and loading
GUI?
1. Windows explorer
2. File manager
3. Authentication
4. Desktop manager
Q5. Which of the following usually provides the interface to get access to the services of
OS?
1. System call
2. Library
3. API
4. All of the above
Q6. Name the program that runs rst after booting the computer as well as loading the
GUI.
1. Windows explorer
ff
fi
2. File manager
3. Authentication
4. None of the above
Q7. Which of the following is the main function of the Command Interpreter?
1. To get and execute next user-speci ed command
2. To handle and maintain all les in OS
3. To provide an interface between application program and API
4. None of the above
————————————————————
Answer:
1. Linux
2. Prevent deadlock
3. Virtual memory
4. Authentication
5. All of the above
6. Authentication
7. To get and execute next user-speci ed command
8. Virtual computer
9. Hardware
10. Memory protection
fi
fi
fi