Skip to main content
← Core interview practiceStep 7 of 7

Prepare for the conversation

Operating Systems interview questions

6 questions to strengthen your understanding. Try your answer before revealing the explanation.

Switch subject

6 questions

Think first. Reveal when ready.
What is the difference between a Process and a Thread?Operating Systems

The explanation

A Process is an execution instance of a program running on an operating system. A Thread is a lightweight unit of execution managed independently by the scheduler within a process.

Feature Process Thread
Memory Space Has its own independent address space (code, data, heap). Shares the address space of its parent process (shares heap, code, data).
Creation Cost Expensive (requires OS allocation of resource structures). Cheap (reuses existing process descriptors).
Context Switching May change address spaces; cost depends on the OS, hardware, and cache state. Threads in the same process share an address space, but still require saving and restoring execution state.
Crash Safety Isolation protects others; one process crash doesn't affect others. A crash in one thread can corrupt shared process space, crashing all threads.

Points to cover in your answer

  • Address Space
  • Context Switching
  • Inter-Process Communication (IPC)
  • Safety

Take it one step further

Try answering the follow-up before moving on.

How do processes communicate with each other (IPC) compared to threads?

What is a Deadlock and what are the 4 conditions required for it?Operating Systems

The explanation

A Deadlock is a state where a set of processes are blocked because each process is holding a resource and waiting for another resource held by some other process in the set.

For a deadlock to occur, the following four Coffman conditions must hold simultaneously:

  1. Mutual Exclusion: At least one resource must be held in a non-shareable mode (only one process can use it at a time).
  2. Hold and Wait: A process must currently hold at least one resource and be waiting to acquire additional resources that are being held by other processes.
  3. No Preemption: Resources cannot be forcibly taken from a process holding them; they must be released voluntarily.
  4. Circular Wait: A process must be waiting for a resource held by a second process, which is waiting for a resource held by a third process... up to the first process, forming a circular chain.

Points to cover in your answer

  • Mutual Exclusion
  • Hold and Wait
  • No Preemption
  • Circular Wait

Take it one step further

Try answering the follow-up before moving on.

How does the Banker's Algorithm avoid unsafe resource allocations, and how does avoidance differ from deadlock prevention?

Explain Virtual Memory and PagingOperating Systems

The explanation

Virtual Memory is a memory management technique that gives each process the illusion of a large, contiguous address space, while the actual physical memory (RAM) may be fragmented and smaller than the virtual address space.

Paging: - The virtual address space is divided into fixed-size blocks called pages (typically 4 KB). - Physical memory is divided into frames of the same size. - A page table maps virtual page numbers to physical frame numbers. - When a process accesses an unmapped page, a page fault occurs and the OS loads the page from disk (swap) into a free frame.

Benefits: - Processes can use more memory than physically available (using disk as backing store). - Isolates processes from each other (each has its own page table). - Simplifies memory allocation (no external fragmentation). - Supports shared memory via shared pages (e.g., shared libraries).

TLB (Translation Lookaside Buffer): A hardware cache for recently used page table entries, reducing the overhead of virtual-to-physical address translation.

Points to cover in your answer

  • Page table
  • Page fault
  • Swap space
  • TLB
  • MMU
  • Demand paging
  • Internal fragmentation

Take it one step further

Try answering the follow-up before moving on.

What is the difference between paging and segmentation? What is thrashing?

Compare Contiguous vs Non-Contiguous Memory AllocationOperating Systems

The explanation

Contiguous Memory Allocation: - Each process occupies a single contiguous block of memory. - Fixed Partitioning: Memory divided into fixed-size partitions; internal fragmentation problem. - Dynamic Partitioning: Partitions created dynamically based on process needs; external fragmentation (solved by compaction). - Pros: Simple implementation, fast address translation. - Cons: External fragmentation limits utilization; difficult to grow processes dynamically.

Non-Contiguous Memory Allocation: - Process memory is divided into pages/segments that can be placed anywhere in physical memory. - Paging: Fixed-size pages (no external fragmentation, some internal fragmentation). - Segmentation: Variable-size segments matching logical divisions (code, data, stack); external fragmentation possible. - Pros: Efficient memory utilization, supports virtual memory, processes can grow easily. - Cons: Overhead of page table lookups (mitigated by TLB), more complex memory management hardware.

Points to cover in your answer

  • External vs Internal fragmentation
  • Compaction
  • Paging vs Segmentation
  • MMU complexity

Take it one step further

Try answering the follow-up before moving on.

What is the optimal page size? How does the OS choose which page to evict during a page fault?

What is the difference between a process and a thread?Operating Systems

The explanation

A process has its own virtual address space and operating-system resources. Threads within one process share that process's address space and many resources, but each thread has its own execution state, including a stack and registers.

Sharing memory makes communication cheap, but also creates synchronization problems: two threads can race while updating the same data. Separate processes provide stronger isolation; communicating across them usually requires an IPC mechanism. The best choice depends on isolation, failure containment, and workload, not just creation cost.

Example: A web server can run several worker processes to isolate failures and multiple threads within a worker to handle concurrent blocking I/O. A lock may protect shared in-process state between threads, while workers need an external store or IPC to coordinate. Processes are not automatically safe from every shared-data bug: they can still race through a common database. Discuss the workload and failure model before choosing a concurrency unit.

Points to cover in your answer

  • Address space; shared memory; per-thread stack; synchronization; isolation

Take it one step further

Try answering the follow-up before moving on.

Can one thread crash the entire process? How would you avoid a data race?

What happens during a page fault?Operating Systems

The explanation

A page fault occurs when a process accesses a virtual page whose current page-table entry cannot satisfy the access. The CPU traps into the kernel. The kernel checks whether the access is valid, then may map a page already in memory, allocate a new page, or load data from storage. An invalid access leads to an error or process termination.

A page fault is not automatically a bug: demand paging and copy-on-write deliberately use faults. A major fault requires storage I/O; a minor fault can be resolved without it. Excessive major faults can make an application slow even if CPU usage looks low.

Points to cover in your answer

  • Trap to kernel; validity check; demand paging; minor versus major faults

Take it one step further

Try answering the follow-up before moving on.

How is a page fault different from a segmentation fault?

Step 7 of 7 · Core interview practice

Put this step into practice.

Explain processes, threads, and deadlock using concrete examples.

Enable JavaScript to save progress. You can still continue through the path.