Top Interview Questions
An Operating System (OS) is system software that acts as an interface between computer hardware and the user. It manages hardware resources, provides common services for computer programs, and ensures that applications execute efficiently and securely. Without an operating system, a computer would be unable to perform meaningful tasks, as users and applications would have no direct way to interact with hardware components such as the CPU, memory, disk, and input/output devices.
In simple terms, the operating system is the backbone of a computer system, responsible for controlling and coordinating all activities within the system.
The primary objectives of an operating system are:
Convenience – Makes the computer easier to use.
Efficiency – Utilizes hardware resources effectively.
Resource Management – Allocates and deallocates resources such as CPU, memory, and devices.
Security and Protection – Protects data and programs from unauthorized access.
Reliability – Ensures consistent system operation even in the presence of errors.
A process is a program in execution. The operating system is responsible for:
Creating and terminating processes
Scheduling processes on the CPU
Managing process synchronization and communication
Handling deadlocks and starvation
Modern operating systems support multitasking, allowing multiple processes to run concurrently by rapidly switching the CPU between tasks.
Memory management involves controlling and coordinating computer memory. The OS:
Keeps track of memory usage
Allocates memory to processes when required
Deallocates memory when processes terminate
Supports techniques like paging, segmentation, and virtual memory
Virtual memory allows the system to run programs larger than physical memory by using disk space as an extension of RAM.
The operating system manages data stored on secondary storage devices such as hard disks and SSDs. Responsibilities include:
Creating, reading, writing, and deleting files
Organizing files into directories
Maintaining file metadata (size, permissions, timestamps)
Enforcing file access permissions
Popular file systems include NTFS, FAT32, ext4, and APFS.
Device management ensures smooth interaction between hardware devices and software. The OS:
Uses device drivers to communicate with hardware
Handles input/output operations
Allocates devices to processes
Manages buffering, caching, and spooling
Examples of devices include printers, keyboards, mice, scanners, and network cards.
CPU scheduling determines which process gets CPU time and for how long. Scheduling algorithms include:
First Come First Serve (FCFS)
Shortest Job First (SJF)
Priority Scheduling
Round Robin
Efficient CPU scheduling improves system throughput and responsiveness.
The OS protects system resources and user data by:
Authentication (user login)
Authorization (access control)
Encryption
Process isolation
Security mechanisms prevent malicious programs from damaging the system or accessing sensitive data.
The operating system provides an interface for user interaction:
Command Line Interface (CLI) – Text-based interaction (e.g., Linux terminal)
Graphical User Interface (GUI) – Visual interaction using windows, icons, and menus (e.g., Windows, macOS)
In batch systems, jobs are collected and processed in batches without user interaction. These systems were common in early computers.
Time-sharing systems allow multiple users to interact with the computer simultaneously by sharing CPU time. Example: UNIX.
A distributed OS manages a group of computers and makes them appear as a single system. Resources are shared across machines.
This OS runs on a server and manages network resources, users, and security. Example: Windows Server.
RTOS is designed for systems requiring strict timing constraints, such as medical equipment, robotics, and aerospace systems.
Designed for smartphones and tablets. Examples include Android and iOS.
The kernel is the core of the operating system. It manages:
CPU scheduling
Memory management
Device communication
System calls
Types of kernels:
Monolithic Kernel
Microkernel
Hybrid Kernel
The shell is an interface between the user and the kernel. It interprets user commands and executes them.
These are programs that perform maintenance tasks such as disk cleanup, file compression, and system monitoring.
The OS provides several services to programs:
Program execution
I/O operations
File manipulation
Error detection
Resource allocation
Accounting and logging
Windows – Widely used in personal computers
Linux – Open-source and popular in servers and embedded systems
macOS – Used in Apple computers
UNIX – Powerful multi-user OS used in enterprises
Android – Mobile OS based on Linux
iOS – Apple’s mobile operating system
The operating system plays a crucial role in:
Enabling hardware usability
Improving system performance
Providing security
Supporting application development
Enabling multitasking and multi-user environments
Without an operating system, a computer is just a collection of hardware components with no coordination.
Answer:
An Operating System is system software that acts as an interface between computer hardware and the user. It manages hardware resources, provides a platform for applications, and ensures smooth execution of processes. Examples: Windows, Linux, macOS, Android.
Answer:
Process Management – Managing process creation, execution, and termination.
Memory Management – Allocating and deallocating memory efficiently.
File System Management – Managing files, directories, and storage.
Device Management – Controlling input/output devices.
Security and Access Control – Protecting data and resources.
User Interface Management – Providing CLI or GUI for user interaction.
Answer:
Batch OS – Executes jobs in batches; e.g., early IBM systems.
Time-Sharing OS – Allows multiple users to share CPU simultaneously.
Distributed OS – Manages multiple computers as a single system; e.g., Amoeba.
Real-Time OS (RTOS) – Provides immediate response; e.g., VxWorks.
Network OS – Supports networking and resource sharing; e.g., Novell NetWare.
Mobile OS – Optimized for mobile devices; e.g., Android, iOS.
Answer:
A process is a program in execution, which includes the program code, current activity, CPU registers, memory, and I/O status. It is the basic unit of CPU utilization.
| Feature | Process | Thread |
|---|---|---|
| Definition | Program in execution | Lightweight process inside a process |
| Memory | Has its own memory | Shares memory with other threads in the same process |
| Creation | Higher overhead | Lower overhead |
| Communication | IPC needed | Direct memory sharing |
Answer:
New – Process is being created.
Ready – Process is waiting to be assigned to CPU.
Running – Process is executing on CPU.
Waiting/Blocked – Process waiting for an event or I/O.
Terminated – Process has finished execution.
Answer:
A thread is the smallest unit of CPU execution within a process. Threads share the process’s memory but have their own program counter, stack, and registers.
Answer:
Multithreading allows multiple threads to run concurrently within the same process, improving CPU utilization and application responsiveness.
Answer:
A deadlock is a situation where a set of processes are waiting for each other indefinitely, and none of them can proceed.
Answer:
Mutual Exclusion – At least one resource must be held in a non-shareable mode.
Hold and Wait – A process holding a resource is waiting for another resource.
No Preemption – Resources cannot be forcibly taken from a process.
Circular Wait – A circular chain of processes exists, each waiting for a resource held by the next.
| Feature | Preemptive | Non-Preemptive |
|---|---|---|
| CPU allocation | Can forcibly take CPU from a process | Process releases CPU voluntarily |
| Example | Round Robin | First-Come-First-Served (FCFS) |
Answer:
FCFS (First-Come-First-Served) – Processes are scheduled in arrival order.
SJF (Shortest Job First) – Process with shortest burst time is executed first.
Priority Scheduling – Process with highest priority is executed first.
Round Robin (RR) – Processes are executed in a cyclic order with time quantum.
Multilevel Queue Scheduling – Processes are divided into queues based on priority or type.
Answer:
Context switching is the process of storing the state of a currently running process and loading the state of the next process to execute, allowing CPU to switch between processes.
Answer:
Virtual memory allows a computer to use disk space as an extension of RAM, giving the illusion of more memory. Techniques include paging and segmentation.
Answer:
Paging is a memory management scheme where physical memory is divided into fixed-size blocks called frames, and logical memory into pages. Pages are mapped to frames using a page table.
Answer:
Segmentation divides a program into variable-sized segments based on logical units like functions, objects, or arrays, improving modularity and protection.
| Feature | Paging | Segmentation |
|---|---|---|
| Size | Fixed-size | Variable-size |
| Concept | Divides memory into pages | Divides memory into logical segments |
| Addressing | Page number + offset | Segment number + offset |
| External fragmentation | No | Possible |
Answer:
Thrashing occurs when a system spends more time swapping pages in and out of memory than executing processes, leading to low CPU utilization.
Answer:
A file system is a method used by an OS to store, organize, and manage files on storage devices. Examples: FAT32, NTFS, ext4.
Sequential Access – Read/write data in order.
Direct/Random Access – Access data at any position.
Answer:
A semaphore is a synchronization tool used to control access to shared resources by multiple processes. Types:
Binary Semaphore – Values 0 or 1.
Counting Semaphore – Integer values to control multiple resources.
Answer:
A mutex is a locking mechanism to ensure that only one thread accesses a shared resource at a time.
| Feature | Semaphore | Mutex |
|---|---|---|
| Value | Can be >1 | Binary (0/1) |
| Ownership | No owner | Owned by a thread |
| Use | Multiple threads | Single thread access |
Answer:
Starvation occurs when a process waits indefinitely because higher-priority processes keep getting CPU.
Answer:
Aging is a technique to gradually increase the priority of a process that waits in the ready queue for a long time, preventing starvation.
Answer:
The kernel is the core component of an OS, responsible for process management, memory management, device management, and system calls.
Monolithic Kernel – Entire OS runs in kernel mode; fast but less secure.
Microkernel – Only essential services run in kernel; modular and secure.
Hybrid Kernel – Combination of monolithic and microkernel.
Answer:
An interrupt is a signal to the CPU indicating an event that needs immediate attention. Types:
Hardware Interrupt – Generated by hardware (keyboard, mouse).
Software Interrupt – Generated by software or system calls.
Answer:
Spooling (Simultaneous Peripheral Operations On-Line) is a process where data is temporarily held in a buffer before sending to an output device like a printer.
Answer:
A shell is a user interface (CLI or GUI) that allows users to interact with the OS and execute commands.
Answer:
A memory leak occurs when a program allocates memory but fails to release it, leading to wasted memory and potential system crash.
| Feature | Logical Address | Physical Address |
|---|---|---|
| Definition | Generated by CPU | Actual location in RAM |
| View | Process view | Hardware view |
| Translation | Needs MMU | No translation |
Answer:
I/O management coordinates and controls input/output operations, using techniques like buffering, caching, spooling, and device drivers.
Answer:
DMA allows devices to transfer data directly to/from memory without CPU intervention, increasing efficiency.
Answer:
A boot loader is a program that loads the OS into memory during system startup.
Paging – Fixed-size memory blocks, no external fragmentation.
Segmentation – Variable-size, logical division, possible fragmentation.
Virtual Memory – Uses disk as RAM extension; supports paging and segmentation.
| Feature | OS | Application Software |
|---|---|---|
| Purpose | Manage hardware and resources | Solve user-specific problems |
| Examples | Windows, Linux | MS Office, Photoshop |
| Dependency | Runs independently | Depends on OS |
Answer:
RTOS guarantees task execution within a fixed time frame, used in embedded systems, robotics, and critical systems. Types: Hard RTOS and Soft RTOS.
Answer:
A page fault occurs when a program accesses a page not currently in physical memory, prompting the OS to fetch it from disk.
| Feature | Blocking I/O | Non-blocking I/O |
|---|---|---|
| CPU Wait | Waits until I/O completes | CPU continues execution |
| Efficiency | Less efficient | More efficient |
Answer:
A file descriptor is an integer representing an open file or I/O resource used by a process in Unix/Linux systems.
| Feature | Hard Link | Soft Link (Symbolic) |
|---|---|---|
| Reference | Points to inode | Points to file path |
| Across File Systems | Not allowed | Allowed |
| Deletion effect | Original file remains | Broken if target deleted |
Answer:
Swapping is moving a process from main memory to disk and back to free up RAM for other processes.
Answer:
When the OS spends most time swapping pages in/out due to insufficient memory, reducing CPU efficiency.
| Feature | Multitasking | Multiprocessing |
|---|---|---|
| CPU | Single CPU | Multiple CPUs |
| Execution | Interleaved | Parallel |
| Example | Windows | Linux SMP |
Answer:
A race condition occurs when multiple processes/threads access shared data simultaneously, leading to unpredictable results.
Answer:
Using synchronization mechanisms like:
Mutexes
Semaphores
Monitors
Locks
| Feature | User Mode | Kernel Mode |
|---|---|---|
| Privileges | Limited | Full |
| Execution | Cannot access hardware directly | Can access hardware and memory |
| Example | Application programs | OS kernel |
Answer:
A system call is an API provided by the OS for applications to request services like file I/O, process control, and communication.
Answer:
Steps during system startup:
Power-On Self Test (POST)
Boot loader loads OS
Kernel initialization
System and user processes start
Answer:
Internal Fragmentation – Wasted memory inside allocated blocks.
External Fragmentation – Wasted memory outside allocated blocks.
Answer:
Swap space is disk space used to store inactive pages from RAM to free memory.
Logical memory: Seen by the process.
Physical memory: Actual RAM used by OS.
Kernel – Core OS, manages hardware.
Shell – Interface for user to interact with OS.
Answer:
Ensures orderly execution of processes to prevent conflicts when sharing resources. Tools: semaphores, mutexes, monitors, critical sections.
| Feature | Monolithic | Microkernel |
|---|---|---|
| Structure | All services in kernel | Minimal kernel + user-space services |
| Performance | Fast | Slightly slower |
| Security | Less secure | More secure |
Answer:
An Operating System is system software that acts as an interface between hardware and users/applications. It manages hardware resources like CPU, memory, I/O devices, and provides services for application programs.
Example: Windows, Linux, macOS, Android, iOS.
Key Points:
Resource management
Process management
Memory management
File system management
Security & user management
Answer:
Batch OS: Executes jobs in batches; no interaction with users (e.g., IBM Mainframe OS).
Time-Sharing OS: Allows multiple users to share CPU time simultaneously (e.g., Unix).
Distributed OS: Manages a group of independent computers and makes them appear as a single system (e.g., Amoeba OS).
Real-Time OS (RTOS): Used where timing is critical; can be hard or soft real-time (e.g., VxWorks).
Network OS: Provides services to computers connected in a network (e.g., Novell NetWare).
Mobile OS: Optimized for smartphones/tablets (e.g., Android, iOS).
Answer:
| Feature | Kernel Mode | User Mode |
|---|---|---|
| Privilege Level | High (full access to hardware) | Low (restricted access) |
| Access | Direct access to hardware & memory | Access via system calls only |
| Examples | OS Kernel, Device Drivers | Applications, User Programs |
| Risk | Errors can crash OS | Errors affect only the program |
Scenario: When a user program requests disk access, it triggers a system call, switching from user mode to kernel mode.
Answer:
A process is a program in execution. It includes:
Program Counter (PC)
Stack (for function calls & local variables)
Data Section
Heap (for dynamic memory)
States of a process: New → Ready → Running → Waiting → Terminated
Example: When you open Chrome, each tab is a separate process.
Answer:
| Feature | Process | Thread |
|---|---|---|
| Memory | Separate memory space | Shares memory within a process |
| Overhead | High (context switching) | Low |
| Communication | Inter-process Communication | Direct (shared memory) |
| Example | Chrome Browser Tabs | Threads within a Chrome tab |
Scenario: Multi-threaded server handles thousands of client requests efficiently using threads.
Answer:
Process Scheduling is the method by which the OS decides which process runs next. It improves CPU utilization, throughput, and response time.
Types of Scheduling:
Long-term: Decides which jobs to admit to the ready queue.
Medium-term: Suspends/resumes processes to balance load.
Short-term: CPU scheduler decides which process runs next.
Algorithms:
FCFS (First Come First Serve) – Simple but can cause convoy effect.
SJF (Shortest Job First) – Minimizes waiting time; risk of starvation.
Priority Scheduling – Uses priority; high risk of starvation.
Round Robin (RR) – Fair, uses time quantum; good for time-sharing.
Multilevel Queue/Feedback Queue – Combines multiple policies.
Answer:
Deadlock occurs when two or more processes are waiting indefinitely for resources held by each other.
Necessary Conditions (Coffman conditions):
Mutual exclusion
Hold and wait
No preemption
Circular wait
Handling Deadlocks:
Prevention – Ensure at least one Coffman condition never holds.
Avoidance – Use algorithms like Banker’s algorithm.
Detection & Recovery – Detect using wait-for graph and terminate processes.
Scenario: Printer and Scanner deadlock if two processes hold one and wait for the other.
Answer:
Memory management ensures efficient allocation and deallocation of RAM.
Techniques:
Contiguous Allocation: Easy but causes fragmentation.
Paging: Breaks memory into fixed-size pages; solves external fragmentation.
Segmentation: Divides memory logically (code, data, stack).
Virtual Memory: Uses disk as an extension of RAM; allows demand paging.
Scenario: Running a 16 GB application on an 8 GB RAM system uses virtual memory with page swapping.
Answer:
Occurs when a program accesses a page not currently in RAM. The OS brings the page from disk.
Example: Accessing a large dataset that doesn’t fit in physical memory triggers page faults.
Handling:
Load page from disk to memory
Update page table
Resume execution
Answer:
A file system manages data storage on disks. It organizes files into directories, controls access, and manages storage allocation.
Components:
File Control Block (FCB) – Metadata like size, type, permissions
Directory structure – Hierarchical (tree) or flat
Allocation methods: Contiguous, Linked, Indexed
Example: NTFS, ext4, FAT32.
Answer:
Context switching is saving the state of a running process and loading the state of the next scheduled process.
Overhead: CPU time is wasted during switching.
Scenario: In multitasking OS, switching between Chrome, VSCode, and Terminal.
Answer:
A system call is a request made by a user program to the OS to perform privileged operations.
Types:
Process control (fork, exit)
File management (open, read, write)
Device management (ioctl)
Communication (pipe, message queues)
Scenario: read() system call reads data from a file into user memory.
Answer:
IPC allows processes to exchange data.
Methods:
Pipes (anonymous or named)
Message queues
Shared memory
Semaphores
Sockets
Scenario: Client-server communication in a distributed application uses sockets.
Answer:
Semaphore is a synchronization primitive used to solve race conditions and coordinate processes.
Types:
Binary semaphore: Only 0 or 1 (like a mutex)
Counting semaphore: Can take non-negative integer values
Scenario: Controlling access to a printer by multiple processes.
Answer:
A critical section is a part of code where shared resources are accessed.
Requirements:
Mutual exclusion
Progress (no process waits forever)
Bounded waiting
Solution: Semaphores, Mutex, Monitors.
Answer:
Mutex is a mutual exclusion object used to prevent concurrent access to a resource by multiple threads.
Scenario: Only one thread can update a bank account balance at a time.
Already partially covered in Question 6
Additional advanced algorithms:
Multilevel Feedback Queue: Dynamically adjusts priority based on behavior.
Shortest Remaining Time First (SRTF): Preemptive SJF variant.
Metrics for evaluation: Turnaround time, waiting time, response time, CPU utilization.
Answer:
Thrashing occurs when the OS spends more time swapping pages than executing processes, due to insufficient memory.
Solution:
Increase RAM
Use working set model
Limit multiprogramming degree
| Feature | Preemptive Scheduling | Non-Preemptive Scheduling |
|---|---|---|
| CPU takeover | OS can suspend running process | Process runs till completion |
| Examples | Round Robin, SJF (preemptive) | FCFS, SJF (non-preemptive) |
| Use-case | Interactive systems | Batch systems |
Answer:
Swap space is disk space used as virtual memory. It helps when RAM is insufficient.
Scenario: Linux often uses /swapfile or dedicated swap partition.
Answer:
Paging is a memory management scheme that eliminates external fragmentation by dividing physical memory into fixed-size frames and logical memory into pages.
Key Points:
Logical addresses are divided into page number and page offset.
Physical memory uses frame number + offset.
Page tables map virtual pages to physical frames.
Scenario: A process of 50 KB is loaded into memory with 4 KB pages. OS maps 13 pages into different frames in RAM.
Answer:
Segmentation divides memory into logical units like code, data, stack, or functions. Each segment has a base and limit.
Difference from Paging:
Paging: fixed-size, no logical meaning
Segmentation: variable-size, logically meaningful
Example: Code segment 10 KB, Data segment 5 KB, Stack segment 2 KB.
Answer:
Virtual memory allows execution of programs larger than physical memory using disk space.
Techniques:
Demand Paging: Load pages only when required.
Page Replacement: Replace pages using algorithms like LRU, FIFO, Optimal.
Scenario: Running a 16 GB application on an 8 GB RAM system uses virtual memory with page swapping.
Answer:
| Algorithm | Description | Pros | Cons |
|---|---|---|---|
| FIFO | Replace oldest page | Simple | High page fault rate |
| LRU | Replace least recently used | Good performance | Needs tracking |
| Optimal | Replace page that won’t be used for longest | Minimum page fault | Impossible in real OS |
| LFU | Replace least frequently used | Useful in some apps | Old pages can stay too long |
Scenario: Browser tab usage can be modeled using LRU to manage cache pages.
Answer:
Thrashing occurs when too many processes compete for memory, causing excessive page swapping and CPU idle time.
Detection: High page fault rate, low CPU utilization.
Solution: Reduce multiprogramming level, increase RAM, or use working set model.
Answer:
| Feature | Kernel Space | User Space |
|---|---|---|
| Privileges | Full | Limited |
| Access | Hardware | System calls only |
| Crash Risk | OS crash | Only app crash |
| Examples | Device drivers, OS core | Applications, Scripts |
Scenario: When you open a file, user-space requests go via system calls, switching to kernel mode.
Answer:
System calls allow applications to request OS services.
Categories:
Process control: fork(), exit()
File operations: open(), read(), write()
Device operations: ioctl(), read(), write()
Communication: pipe(), msgget(), socket()
Scenario: Reading from a file triggers a read() system call.
Answer:
IPC allows processes to share data and synchronize.
Mechanisms:
Pipes (unidirectional, bidirectional with named pipes)
Message Queues
Shared Memory
Semaphores
Sockets
Scenario: Web server (process A) sends logs to logging process (process B) using shared memory.
Answer:
Semaphore is a synchronization primitive to avoid race conditions.
Types:
Binary semaphore (mutex): 0 or 1
Counting semaphore: Non-negative integer
Operations:
wait() or P() – Decrement semaphore
signal() or V() – Increment semaphore
Scenario: Controlling access to a printer by multiple processes using a binary semaphore.
Answer:
Deadlock Prevention: Ensure one of Coffman’s conditions doesn’t hold.
Deadlock Avoidance: Use Banker’s Algorithm for resource allocation.
Deadlock Detection & Recovery: Use Wait-for Graph and terminate/restart processes.
Scenario: Two processes holding Printer & Scanner indefinitely → deadlock detected and resolved by terminating one process.
| Feature | Monolithic Kernel | Microkernel |
|---|---|---|
| Size | Large | Small |
| Modules | All OS services in kernel | Only essential services |
| Performance | Fast | Slower due to message passing |
| Stability | Less stable | More stable |
| Example | Linux, Unix | Mach, Minix |
Answer:
File system provides:
Storage allocation (contiguous, linked, indexed)
File naming & access control
Directory structures (hierarchical/tree, flat)
Example: Linux uses ext4, Windows uses NTFS.
Answer:
Improves disk I/O performance.
| Algorithm | Description |
|---|---|
| FCFS | First come first served |
| SSTF | Shortest seek time first |
| SCAN | Elevator algorithm |
| C-SCAN | Circular scan for fairness |
| LOOK/C-LOOK | Variation of SCAN with dynamic end detection |
Scenario: Hard drive head moves optimally using SCAN to service read/write requests.
Answer:
RTOS ensures tasks are executed within strict timing constraints.
Types:
Hard real-time: Deadline must be met (e.g., pacemakers)
Soft real-time: Deadlines desirable but not strict (e.g., video streaming)
Features:
Deterministic scheduling
Minimal latency
Predictable interrupt handling
Answer:
Swapping moves processes between RAM and disk to free memory.
Scenario: Linux swaps out idle processes to disk to free RAM for active processes.
| Feature | Logical Address | Physical Address |
|---|---|---|
| Definition | Generated by CPU | Actual RAM address |
| Viewpoint | Program/Compiler | Memory unit |
| Translation | Through MMU | Direct |
| Example | Virtual addresses in process | Actual memory frames |
Answer:
Multiple threads within a single process share memory but execute independently.
Benefits:
Better CPU utilization
Responsiveness
Resource sharing
Scenario: Web server handles multiple client requests using threads.
Answer:
Occurs when multiple processes access shared resources concurrently and the final outcome depends on execution order.
Solution: Mutexes, semaphores, monitors.
Scenario: Two threads updating a bank account simultaneously → wrong balance.
Answer:
Switching CPU from one process to another.
Steps:
Save current process state (PC, registers)
Load next process state from PCB
Resume execution
Scenario: Multitasking OS switches between browser, IDE, and terminal.
Answer:
Occurs when low-priority processes never get CPU time due to high-priority processes continuously running.
Solution: Aging – gradually increase priority of waiting processes.
Answer:
OS security ensures data and resource safety from malicious users or processes.
Key Mechanisms:
Authentication: Verifies identity (passwords, biometrics).
Authorization: Grants access based on user permissions.
Encryption: Protects sensitive data (AES, RSA).
Access Control:
Discretionary Access Control (DAC) – owner decides access
Mandatory Access Control (MAC) – OS enforces strict policies
Audit Trails: Logs all user activities for detection and recovery.
Scenario: Linux chmod sets file permissions to prevent unauthorized access.
Answer:
A device driver is software that controls and communicates with hardware.
Types:
Character devices: Read/write data sequentially (keyboard, mouse)
Block devices: Read/write data in blocks (disk, SSD)
Network devices: Ethernet, Wi-Fi cards
Scenario: Printer driver converts OS print commands into signals the printer hardware understands.
Answer:
The kernel uses data structures to manage processes, memory, files, and devices.
Key Structures:
Process Control Block (PCB): Stores process info (state, registers, priority).
File Control Block (FCB): Stores metadata of files.
Page Tables: Maps virtual pages to physical frames.
Ready Queue / Wait Queue: Maintains process scheduling.
Scenario: During context switch, PCB is used to save and load process state.
Answer:
Linux:
Monolithic kernel
Supports preemptive multitasking
Uses virtual memory, paging, and segmentation
File systems: ext3/ext4, XFS
System calls via syscall interface
Windows:
Hybrid kernel (monolithic + microkernel)
Supports threads, processes, and preemptive multitasking
NTFS file system
Device drivers managed via Kernel Mode Driver Framework (KMDF)
Scenario: fork() in Linux creates a new process, while Windows uses CreateProcess().
Answer:
Advanced Methods:
Message Passing: Safe for distributed systems.
Shared Memory: Fastest IPC; synchronization via semaphores.
Sockets: Network-based IPC between processes on different machines.
Remote Procedure Call (RPC): Allows a process to execute code on a remote machine.
Scenario: Microservices communicate using sockets and RPC over a network.
Answer:
Detection is needed when deadlock is possible.
Wait-for Graph: Nodes = processes, edge P1→P2 means P1 waits for P2.
Cycle → Deadlock exists.
Banker’s Algorithm: Tracks resources, checks for safe state.
Scenario: If two database transactions hold locks on each other’s resources, OS detects the cycle in wait-for graph and resolves it.
| Feature | Paging | Segmentation | Virtual Memory |
|---|---|---|---|
| Unit | Fixed-size pages | Variable-size segments | Pages + Disk swap |
| Fragmentation | Internal | External | Solves both via demand paging |
| Address Mapping | Page Table | Segment Table | Page Table + Disk mapping |
| Use-case | General memory mgmt | Logical division | Run programs > RAM |
Scenario: Modern OS combines paging and segmentation for efficient memory management.
Answer:
Loadable Kernel Modules allow dynamic addition of functionality to the kernel without rebooting.
Benefits:
Extend kernel features (drivers, filesystems)
Reduce memory usage (load on-demand)
Easier debugging
Scenario: Adding a new USB device driver as a module without restarting Linux.
Answer:
POSIX Threads are standardized threads in Unix/Linux, allowing concurrent execution within a process.
Key Features:
Lightweight threads share process memory
Thread functions: pthread_create, pthread_join, pthread_mutex_lock
Supports synchronization primitives like mutexes and condition variables
Scenario: Multi-threaded server using pthreads for handling multiple clients.
Answer:
| Algorithm | Type | Description |
|---|---|---|
| Rate Monotonic (RM) | Fixed | Priority based on period; shorter period → higher priority |
| Earliest Deadline First (EDF) | Dynamic | Task with earliest deadline gets CPU |
| Least Laxity First (LLF) | Dynamic | Task with least slack time gets CPU |
Scenario: Embedded systems in cars use RM or EDF to ensure safety-critical tasks meet deadlines.
Answer:
OS manages devices to coordinate access and optimize performance.
Techniques:
Polling: CPU repeatedly checks device status (inefficient).
Interrupt-driven: Device notifies CPU on completion.
DMA (Direct Memory Access): Device writes directly to memory, freeing CPU.
Scenario: Disk I/O uses DMA to transfer large data blocks efficiently.
Answer:
Mechanisms:
Mutexes – Mutual exclusion locks
Semaphores – Counting and binary for resource control
Monitors – High-level abstraction encapsulating condition variables and mutexes
Spinlocks – Busy-wait for short critical sections
Scenario: Bank system ensures consistent account balance updates using mutexes.
Answer:
Advanced CPU scheduling algorithm that adjusts process priority dynamically based on behavior.
Features:
Multiple queues with different priorities
Processes that use CPU extensively are lowered in priority
Short processes get fast turnaround
Scenario: OS ensures interactive apps like editors are responsive, while background tasks are deprioritized.
Answer:
VFS is an abstraction layer allowing Linux to support multiple file systems.
Features:
Provides uniform interface for system calls like open(), read(), write()
Supports ext4, NFS, FAT, etc.
Helps OS work with local and network files seamlessly
Scenario: VFS allows mounting both ext4 disk and NFS network share with the same API.
Answer:
| Feature | Swapping | Paging | Segmentation |
|---|---|---|---|
| Unit | Process | Fixed-size pages | Logical segments |
| Purpose | Move entire process | Manage memory efficiently | Logical program division |
| Overhead | High | Medium | Low/Medium |
| Example | Unix swapping | Linux paging | Intel x86 segmentation |
Process & Thread Management: PCB, scheduling, context switch, IPC
Memory Management: Paging, segmentation, virtual memory, thrashing
Deadlock & Synchronization: Deadlock handling, semaphores, mutexes, monitors
File & Device Management: File systems, disk scheduling, device drivers
Advanced OS Topics: Kernel modules, real-time scheduling, Linux/Windows internals, VFS
Security & Protection: Authentication, authorization, DAC, MAC