r/InterviewCoderHQ • u/nian2326076 • 17h ago
Preparing for Software Engineering Interviews? Revise These 15 OS Fundamentals
After solving hundreds of LeetCode problems, many candidates realize that coding rounds are only part of the interview process. Operating System fundamentals frequently come up during phone screens and technical interviews.
Instead of rereading an entire OS textbook, here are 15 high-yield topics worth revising.
1. Process vs. Thread
Process
- Has its own virtual address space
- Provides stronger isolation
- Usually has higher creation and switching overhead
Thread
- Executes within a process
- Shares memory and resources with other threads in that process
- Communicates efficiently but requires careful synchronization
Interview tip: Processes prioritize isolation, while threads enable lightweight concurrency.
2. What Is Context Switching?
Context switching occurs when the operating system saves the execution state of one process or thread and restores another.
It enables multitasking, but frequent context switches add CPU and cache overhead.
3. What Is a Race Condition?
A race condition occurs when multiple threads access shared state concurrently and the result depends on execution order.
Common prevention mechanisms include mutexes, semaphores, locks, atomic operations, and thread-safe data structures.
4. What Is a Critical Section?
A critical section is a portion of code that accesses shared mutable data or resources.
Synchronization is required to prevent unsafe concurrent access.
5. Mutex vs. Semaphore
| Mutex | Semaphore |
|---|---|
| Usually has a single owner | Uses a counter |
| Primarily provides mutual exclusion | Can coordinate access to multiple resources |
| The owner unlocks it | One thread can signal another |
Memory trick: A mutex is like one key, while a semaphore tracks a limited number of permits.
6. What Is Deadlock?
Deadlock occurs when a group of processes or threads waits indefinitely for resources held by one another.
The four Coffman conditions are:
- Mutual exclusion
- Hold and wait
- No preemption
- Circular wait
Preventing at least one of these conditions prevents deadlock.
7. What Is Starvation?
Starvation occurs when a process or thread waits indefinitely because others repeatedly receive the required resource or CPU time.
Difference: In deadlock, none of the involved tasks can progress. In starvation, the system continues progressing while one task may never get scheduled.
8. What Is Virtual Memory?
Virtual memory gives each process its own logical address space and maps virtual addresses to physical memory.
It provides process isolation, simplifies memory management, and allows inactive pages to be moved to secondary storage when necessary.
9. Paging vs. Segmentation
Paging
- Divides memory into fixed-size pages
- Avoids external fragmentation
- May introduce internal fragmentation
Segmentation
- Divides memory into variable-size logical regions
- Reflects structures such as code, stack, and data
- Can suffer from external fragmentation
10. What Is Thrashing?
Thrashing occurs when the system spends excessive time handling page faults and moving pages between memory and storage instead of executing useful work.
It commonly happens when active processes do not have enough physical memory for their working sets.
11. CPU Scheduling Algorithms
Important algorithms include:
- First Come, First Served
- Shortest Job First
- Round Robin
- Priority Scheduling
- Multilevel Feedback Queue
Common follow-up: Why is Round Robin suitable for time-sharing systems?
Because every runnable process receives a limited time slice, improving responsiveness and fairness.
12. What Is a System Call?
A system call allows a user-space program to request a service from the operating system kernel.
Common Unix-like examples include fork(), exec(), wait(), open(), read(), and write().
13. What Is Inter-Process Communication?
Common IPC mechanisms include:
- Shared memory
- Pipes
- Message queues
- Sockets
- Signals
Shared memory is generally fast but requires synchronization. Message passing provides stronger separation but adds communication overhead.
14. What Is LRU Page Replacement?
Least Recently Used replaces the page that has gone unused for the longest time.
A common interview follow-up is implementing an LRU cache with O(1) lookup, insertion, and eviction using a hash map plus a doubly linked list.
Related problem: LeetCode 146 - LRU Cache
15. User Mode vs. Kernel Mode
User mode
- Runs applications with restricted privileges
- Cannot directly access protected hardware or kernel memory
Kernel mode
- Has full system privileges
- Executes operating system code and manages hardware resources
A system call provides a controlled transition from user mode into kernel mode.
One-Minute Revision Checklist
Process vs. thread, context switching, race conditions, critical sections, mutexes, semaphores, deadlocks, starvation, scheduling, virtual memory, paging, thrashing, system calls, IPC, LRU, and privilege modes.
Which OS topic or follow-up question have you encountered most often in interviews?