CS Fundamentals
Common interview and exam questions about Operating Systems with detailed answers — covering process management, memory, file systems, and more.
Introduction
Operating Systems is one of the most frequently tested topics in both university exams and technical interviews. Whether you are appearing for a campus placement, preparing for competitive exams like GATE, or getting ready for your semester finals, OS questions are virtually guaranteed to appear. The questions range from basic definitions to complex scenarios involving scheduling, memory management, and deadlocks.
This chapter presents the most commonly asked questions with detailed answers written in a way that you can adapt for both written exams and verbal interviews. For written exams, you can expand these answers with diagrams. For interviews, focus on clear, concise explanations that demonstrate understanding rather than memorization.
Basic Concepts
What is an Operating System?
An Operating System is system software that acts as an intermediary between computer hardware and users. It manages hardware resources (CPU, memory, storage, I/O devices), provides a user interface (command-line or graphical), runs and manages applications, and provides services like file management and security. Without an OS, users would need to write code for directly controlling hardware — making computers practically unusable for non-experts.
What are the main functions of an Operating System?
Process Management: creating, scheduling, and terminating processes; allocating CPU time fairly among running programs. Memory Management: allocating and deallocating RAM to processes; implementing virtual memory to use disk space as extended RAM. File System Management: organizing files and directories; controlling access permissions. Device Management: managing I/O devices through device drivers; handling device requests from applications. Security: authenticating users; protecting data and resources from unauthorized access.
What is the difference between a program and a process?
A program is a passive entity — it is executable code stored on disk (like a .exe file). A process is an active entity — it is a program in execution with its own memory space, registers, program counter, and state. The same program can have multiple processes running simultaneously (like opening two instances of Notepad — one program, two processes).
Process Management
What are the different states of a process?
A process moves through five states during its lifecycle. New: the process is being created. Ready: the process is loaded in memory and waiting for CPU time. Running: the process is currently being executed by the CPU. Waiting (Blocked): the process is waiting for an event (like I/O completion). Terminated: the process has finished execution.
The typical flow is: New → Ready → Running → Terminated. From Running, a process can move to Waiting (if it needs I/O) or back to Ready (if its time slice expires). From Waiting, it returns to Ready when the awaited event occurs.
What is a context switch?
A context switch occurs when the CPU switches from executing one process to another. The OS saves the current process's state (register values, program counter, memory information) and loads the saved state of the next process. Context switches add overhead because the CPU is doing management work rather than useful computation during the switch. Minimizing context switches improves system performance.
Explain CPU scheduling algorithms.
First Come First Served (FCFS): processes execute in arrival order. Simple but can lead to the "convoy effect" where short processes wait behind long ones. Shortest Job First (SJF): processes with shortest execution time go first. Optimal average waiting time but requires knowing execution times in advance. Round Robin: each process gets a fixed time slice (quantum). When the quantum expires, the process moves to the back of the queue. Fair but performance depends on quantum size. Priority Scheduling: each process has a priority number, higher priority runs first. Can cause starvation of low-priority processes.
Memory Management
What is virtual memory?
Virtual memory is a technique that allows processes to use more memory than physically available in RAM. It uses disk space (swap space or page file) as an extension of RAM. Each process sees a large, continuous address space regardless of actual RAM size. The OS manages moving data between RAM and disk as needed (paging). This enables running programs larger than physical memory and improves multitasking.
What is paging?
Paging divides physical memory into fixed-size blocks called frames and logical memory into same-sized blocks called pages. When a process needs to run, its pages are loaded into available frames (they do not need to be contiguous). A page table maps logical page numbers to physical frame numbers. Advantages: eliminates external fragmentation, allows non-contiguous allocation. Disadvantage: internal fragmentation (last page may not fill its frame completely).
What is a page fault?
A page fault occurs when a process tries to access a page that is not currently in RAM (it is on disk). The OS must: pause the process, find the needed page on disk, load it into a free frame in RAM (possibly swapping out another page if RAM is full), update the page table, and resume the process. Frequent page faults degrade performance significantly (thrashing).
Deadlocks
What is a deadlock?
A deadlock is a situation where two or more processes are each waiting for resources held by the others, creating a circular dependency where none can proceed. Imagine two people in a narrow hallway — each waiting for the other to move aside, so neither can pass.
Four conditions must ALL be present simultaneously for deadlock: Mutual Exclusion (resources cannot be shared), Hold and Wait (processes hold resources while waiting for others), No Preemption (resources cannot be forcibly taken), Circular Wait (a circular chain of processes each waiting for a resource held by the next).
How can deadlocks be handled?
Prevention: ensure at least one of the four conditions cannot occur. Avoidance: use algorithms (like Banker's Algorithm) to ensure the system never enters an unsafe state. Detection and Recovery: allow deadlocks to occur, detect them, and recover (by killing processes or preempting resources). Ignorance: ignore the problem and restart if it occurs (used by most desktop OS due to rarity of deadlocks).
File Systems
What is a file system?
A file system is the method an OS uses to organize, store, and retrieve files on storage devices. It manages how data is physically arranged on disk and maintains metadata (file names, sizes, permissions, locations, timestamps). Common file systems: NTFS (Windows), ext4 (Linux), APFS (macOS), FAT32 (portable drives, limited to 4GB file size).
What is fragmentation?
Internal fragmentation: wasted space within allocated memory blocks (a process gets more space than it needs). External fragmentation: enough total free memory exists but it is scattered in non-contiguous blocks too small to satisfy a request. Compaction (moving processes to create contiguous free space) or paging can solve external fragmentation.
Key Takeaways
- Understand process states and transitions — draw the state diagram from memory
- Know at least three CPU scheduling algorithms with their advantages and disadvantages
- Virtual memory, paging, and page faults are consistently tested topics
- Deadlock requires knowing the four conditions and prevention/avoidance strategies
- Practice explaining concepts in your own words — interviews test understanding, not memorization
- Use real-world analogies to demonstrate deep understanding in interviews
- Draw diagrams for process state transitions, memory allocation, and scheduling timelines
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Operating System Interview Questions — Computer Fundamentals.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Computer Fundamentals topic.
Search Terms
computer-fundamentals, computer fundamentals, computer, fundamentals, interview, preparation, operating, system
Related Computer Fundamentals Topics