OS Questions
OS Questions
An operating system acts as a GUI between the user and the computer
system. In other words, an OS acts as an intermediary between the user
and the computer hardware, managing resources such as memory,
processing power, and input/output operations. Here some examples of
popular operating systems include Windows, MacOS, Linux, Android
etc.
In this article, we provide you with the top 100+ OS interview questions
with answers that cover everything from the basics of OS architecture
to advanced operating systems concepts such as file systems,
scheduling algorithms, and multithreading. Whether you are a fresher
or an experienced IT professional, this article gives you all the
confidence you need to ace your next OS interview.
Table of Content
For more details you can refer States of a Process in Operating Systems
published article.
3. What is a Thread?
Process
We istoprogram
use cookies under
ensure you have action
the best and
browsing threadonisourthe
experience smallest
website. By using segment
our site, you of
acknowledge
instructions that you have
(segment of read and understood
a process) thatourcan
Cookie
bePolicy & Privacyindependently
handled Policy
by a scheduler.
Threads are lightweight processes that share the same address space
including the code section, data section and operating system resources
such as the open files and signals. However, each thread has its own
program counter (PC), register set and stack space allowing them to the
execute independently within the same process context. Unlike
processes, threads are not fully independent entities and can
communicate and synchronize more efficiently making them suitable for
the concurrent and parallel execution in the multi-threaded
environment.
For more details you can refer Difference between Process and Thread
published article.
6. What is Thrashing?
7. What is Buffer?
Level-0
Level-1
Level-2
Level-3
Level-4
Level-5
Level-6
The user can use the logical The user can indirectly
Access address to access the access physical addresses
physical address. but not directly.
Processes are stored and removed from memory, which makes free
memory space, which is too little to even consider utilizing by different
processes. Suppose, that process is not ready to dispense to memory
blocks since its little size and memory hinder consistently staying
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.
26.
We useHow does
cookies to ensureswapping result
you have the best inexperience
browsing betteronmemory
our website.management?
By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
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 fit into
memory at one time
Bounded-buffer
Readers-writers
Dining philosophers
Sleeping barber
The direct Access method is based on a disk model of a file, such that it
is viewed as a numbered sequence of blocks or records. It allows
arbitrary blocks to be read or written. Direct access is advantageous
when accessing large amounts of information. Direct memory access
(DMA) is a method that allows an input/output (I/O) device to send or
receive data directly to or from the main memory, bypassing the CPU to
speed up memory operations. The process is managed by a chip known
as a DMA controller (DMAC).
The cache is a smaller and faster memory that stores copies of the data
from frequently used main memory locations. There are various
different independent caches in a CPU, which store instructions and
data. Cache memory is used to reduce the average time to access data
from the Main memory.
A process that has finished the execution but still has an entry in the
process table to report to its parent process is known as a zombie
process. A child process always first becomes a zombie before being
removed from the process table. The parent process reads the exit
status of the child process which reaps off the child process entry from
the process table.
Switching of CPU to another process means saving the state of the old
process and loading the saved state for the new process. In Context
Switching the process is stored in the Process Control Block to serve
the new process so that the old process can be resumed from the same
part it was left.
Process Thread
If one process is blocked then it The second, thread in the same task
will not affect the execution of could not run, while one server thread
other process is blocked.
The process has its own Process Thread has Parents’ PCB, its own
Control Block, Stack and Thread Control Block and Stack and
Address Space. common Address space.
the process control block (PCB) is a block that is used to track the
process’s execution status. A process control block (PCB) contains
information about the process, i.e. registers, quantum, priority, etc. The
process table is an array of PCBs, that means logically contains a PCB
for all of the current processes in the system.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
52. When is a system in a safe state?
The set of dispatchable processes is in a safe state if there exists at
least one temporal order in which all processes can be run to
completion without resulting in a deadlock.
Program Process
The dispatcher is the module that gives process control over the CPU
after it has been selected by the short-term scheduler. This function
involves the following:
Switching context
Switching to user mode
Jumping to the proper location in the user program to restart that
program
When more than one processes access the same code segment that
segment is known as the critical section. The critical section contains
shared variables or resources which are needed to be synchronized to
maintain the consistency of data variables. In simple terms, a critical
section is a group of instructions/statements or regions of code that
need to be executed atomically such as accessing a resource (file, input
or output port, global data, etc.).
Mutexes
Condition variables
Semaphores
File locks
Multi-threading Multi-tasking
Software solutions
Hardware solutions
Semaphores
Deadlock is a situation when two or more processes wait for each other
to finish and none of them ever finish. Consider an example when two
trains are coming toward each other on the same track and there is only
one track, none of the trains can move once they are in front of each
other. A similar situation occurs in operating systems when there are
two or more processes that hold some resources and wait for resources
held by other(s).
The user can view the The user can never view the
Visibility logical address of a physical address of the
program. program
Internal fragmentation
happens when the method or External fragmentation happens when
process is larger than the the method or process is removed.
memory.
Advantages
Disadvantages
It is faster in comparison of
Segmentation is slow.
segmentation.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Paging Segmentation
Its basic characteristic is its logic Its basic characteristic is its fast
circuit for matching its content. access
Effective access time = (1-p) x Memory access time + p x page fault time
Operation on file:
Create
Open
Read
Write
Rename
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Delete
Append
Truncate
Close
FAT stands for File Allocation Table and this is called so because it
allocates different files and folders using tables. This was originally
designed to handle small file systems and disks. A file allocation table
(FAT) is a table that an operating system maintains on a hard disk that
provides a map of the cluster (the basic units of logical storage on a
hard disk) that a file has been stored in.
Seek Time: Seek time is the time taken to locate the disk arm to a
specified track where the data is to be read or written. So the disk
scheduling algorithm that gives a minimum average seek time is better.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
Bélády’s anomaly
acknowledge is an
that you haveanomaly with some
read and understood page
our Cookie Policyreplacement
& Privacy Policy policies
increasing the number of page frames resulting in an increase in the
number of page faults. It occurs when the First In First Out page
replacement is used.
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.
Enhanced performance.
Multiple applications.
Multi-tasking inside an application.
High throughput and responsiveness.
Hardware sharing among CPUs.
Process termination
Abort all the deadlock processes
We use cookies to Abort one
ensure you haveprocess at a time
the best browsing untilonthe
experience deadlock
our website. is eliminated
By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Resource preemption
Rollback
Selecting a victim
Conclusion
In conclusion, the field of operating systems is a crucial aspect of
computer science, and a thorough understanding of its concepts is
essential for anyone looking to excel in this area. By reviewing the Top
2024 100+ operating systems interview questions we have compiled,
you can gain a deeper understanding of the key principles and concepts
of OS and be better prepared to tackle any interview questions that may
come your way. Remember to study and practice regularly, and use
these questions as a starting point to delve deeper into the complex
world of operating systems. With dedication and hard work, you can
become
We use cookiesan expert
to ensure in this
you have field
the best andexperience
browsing succeed in website.
on our any OS-related
By using our site,job
you or
interview.
acknowledge that you have read and understood our Cookie Policy & Privacy Policy