Operating System Interview Questions and Answers: 47 for Freshers

Quick answer: These 47 Operating System interview questions and answers cover what is asked most in software engineer, system and embedded developer interviews: OS basics, processes and threads, CPU scheduling, synchronization and deadlocks, memory management, and file systems and storage. Key answers include short code examples.

Read each answer, then close the page and explain it aloud in two or three sentences. That is exactly what interviewers check.

Contents

1. Operating System Basics Interview Questions

Q1. What is an operating system?

An operating system is system software that manages hardware and software resources and provides services to programs. It handles processes, memory, files, devices and security, and gives users an interface. Examples are Windows, Linux, macOS and Android.

Q2. What are the main functions of an operating system?

Process management, memory management, file system management, device and I/O management, security and access control, networking, and providing a user interface.

Q3. What is the kernel?

The kernel is the core of the operating system that runs in privileged mode and directly manages the CPU, memory and devices. Other programs request its services through system calls.

Q4. What is the difference between a monolithic kernel and a microkernel?

A monolithic kernel, such as Linux, runs most services (file systems, drivers) in kernel space, which is fast but less isolated. A microkernel keeps only essential functions in the kernel and runs other services in user space, which is more reliable but has more communication overhead.

Q5. What is a system call?

A system call is how a program asks the kernel for a service, such as reading a file (read), creating a process (fork) or allocating memory. It switches the CPU from user mode to kernel mode.

Q6. What is the difference between user mode and kernel mode?

In user mode, programs have restricted access and cannot touch hardware directly. In kernel mode, the OS has full access to hardware and memory. This separation protects the system from faulty programs.

Q7. What are the types of operating systems?

Batch, multiprogramming, multitasking (time-sharing), multiprocessing, distributed, real-time (hard and soft) and embedded operating systems.

Q8. What is booting?

Booting is the process of starting a computer: firmware (BIOS or UEFI) runs self-tests, finds the boot loader, which loads the kernel into memory, and the kernel then starts system services.

2. Processes and Threads Interview Questions

Q9. What is the difference between a program and a process?

A program is passive code stored on disk. A process is a program in execution, with its own memory, program counter, registers and resources.

Q10. What are the states of a process?

New, Ready, Running, Waiting (blocked) and Terminated. A process moves from Ready to Running when scheduled, to Waiting when it needs I/O, and back to Ready when the I/O completes.

Q11. What is a Process Control Block (PCB)?

The PCB is a data structure the OS keeps for each process, storing its ID, state, program counter, registers, memory information, open files and scheduling information.

Q12. What is a context switch?

A context switch saves the state of the running process into its PCB and loads the state of the next process. It allows multitasking but adds overhead, because no useful work is done during the switch.

Q13. What is the difference between a process and a thread?

A process has its own separate memory space. A thread is a lighter unit of execution inside a process that shares the process's memory and resources with other threads. Creating and switching threads is cheaper than processes.

Q14. What is the difference between user-level and kernel-level threads?

User-level threads are managed by a library without kernel knowledge, so switching is fast, but one blocking call can block all of them. Kernel-level threads are managed by the OS, so they can run on multiple CPUs and block independently.

Q15. What is inter-process communication (IPC)?

IPC lets processes exchange data and coordinate, using pipes, message queues, shared memory, sockets and signals.

Q16. What are zombie and orphan processes?

A zombie process has finished but still has an entry in the process table because its parent has not read its exit status. An orphan process is still running after its parent has terminated; on Linux it is adopted by init or systemd.

3. CPU Scheduling Interview Questions

Q17. What is CPU scheduling?

CPU scheduling decides which ready process gets the CPU next. Goals include high CPU utilisation and throughput, and low waiting, turnaround and response times.

Q18. What is the difference between preemptive and non-preemptive scheduling?

In preemptive scheduling, the OS can take the CPU away from a running process, for example when its time slice ends or a higher-priority process arrives. In non-preemptive scheduling, a process keeps the CPU until it finishes or waits for I/O.

Q19. Explain FCFS, SJF, Priority and Round Robin scheduling.

FCFS runs processes in arrival order and is simple but can cause long waits (convoy effect). SJF runs the shortest job first and gives the minimum average waiting time, but needs burst times and can starve long jobs. Priority scheduling runs the highest priority first and can starve low priorities. Round Robin gives each process a fixed time quantum in turn, which suits time-sharing systems.

Q20. What are turnaround time, waiting time and response time?

Turnaround time = completion time − arrival time. Waiting time = turnaround time − burst time. Response time = time of first CPU allocation − arrival time.

Q21. What is starvation and how is it solved?

Starvation happens when a process waits indefinitely because others are always chosen first, as in priority scheduling. Aging solves it by gradually increasing the priority of waiting processes.

Q22. What is multilevel queue scheduling?

Processes are divided into separate queues, such as system, interactive and batch, each with its own scheduling algorithm and priority. In multilevel feedback queues, processes can move between queues based on their behaviour.

Preparing for a Operating System interview? We run live one-to-one classes and mock interviews in operating systems, C and core computer science subjects, arranged around your free time. Chat on WhatsApp.

4. Synchronization and Deadlocks Interview Questions

Q23. What is a race condition?

A race condition occurs when two or more threads access shared data at the same time and the result depends on the order of execution, leading to wrong results.

Q24. What is the critical section problem?

A critical section is code that accesses shared resources. A solution must provide mutual exclusion (only one process inside at a time), progress and bounded waiting.

Q25. What is the difference between a mutex and a semaphore?

A mutex is a lock that one thread owns at a time and must release itself. A semaphore is an integer counter with wait (P) and signal (V) operations; a counting semaphore allows a set number of threads, and a binary semaphore behaves like a lock.

Q26. What is a deadlock?

A deadlock is a state where a set of processes are each waiting for a resource held by another process in the set, so none of them can continue.

Q27. What are the four necessary conditions for deadlock?

Mutual exclusion, hold and wait, no preemption and circular wait. All four must hold at the same time for a deadlock to occur.

Q28. How can deadlocks be handled?

Prevention (break one of the four conditions, such as ordering resources to avoid circular wait), avoidance (grant requests only if the system stays in a safe state, as in the Banker's algorithm), detection and recovery (find cycles and kill or roll back processes), or ignoring the problem, as many general-purpose systems do.

Q29. What is the Banker's algorithm?

The Banker's algorithm avoids deadlock by checking whether granting a resource request keeps the system in a safe state, where there is an order in which all processes can finish with the available resources.

Q30. What are the classic synchronization problems?

The producer–consumer (bounded buffer) problem, the readers–writers problem and the dining philosophers problem.

5. Memory Management Interview Questions

Q31. What is memory management?

Memory management allocates and frees main memory for processes, keeps processes from accessing each other's memory, and makes efficient use of limited RAM.

Q32. What is the difference between logical and physical addresses?

A logical (virtual) address is generated by the CPU for a program. A physical address is the actual location in RAM. The Memory Management Unit (MMU) translates logical addresses into physical ones.

Q33. What is the difference between internal and external fragmentation?

Internal fragmentation is unused space inside an allocated block, because the block is bigger than needed. External fragmentation is free memory split into small non-contiguous pieces that cannot satisfy a large request. Compaction and paging reduce external fragmentation.

Q34. What is paging?

Paging divides logical memory into fixed-size pages and physical memory into frames of the same size. A page table maps pages to frames, so a process does not need contiguous physical memory, which removes external fragmentation.

Q35. What is segmentation?

Segmentation divides a program into variable-sized logical segments, such as code, data and stack, each with its own base and limit. It matches the programmer's view but can cause external fragmentation.

Q36. What is a TLB?

The Translation Lookaside Buffer is a small, fast cache of recent page-table entries. A TLB hit avoids an extra memory access for address translation.

Q37. What is virtual memory?

Virtual memory lets a process use more memory than physically available by keeping only the needed pages in RAM and the rest on disk. It also isolates processes from each other.

Q38. What is demand paging and a page fault?

In demand paging, a page is loaded into memory only when it is first accessed. A page fault occurs when the requested page is not in RAM, so the OS loads it from disk.

Q39. What are the page replacement algorithms?

FIFO replaces the oldest page. LRU replaces the page not used for the longest time. Optimal replaces the page that will not be used for the longest time in the future; it is ideal but impossible to implement exactly and is used for comparison.

Q40. What is Belady's anomaly?

Belady's anomaly is when increasing the number of frames causes more page faults. It can happen with FIFO, but not with LRU or Optimal.

Q41. What is thrashing?

Thrashing occurs when a system spends more time swapping pages in and out than executing processes, because too many processes compete for too little memory. Reducing the degree of multiprogramming or adding RAM fixes it.

6. File Systems, Storage and Linux Interview Questions

Q42. What is a file system?

A file system organises how data is stored, named and retrieved on storage devices, using files, directories and metadata. Examples are NTFS, ext4, FAT32 and APFS.

Q43. What are the file allocation methods?

Contiguous allocation (fast but causes fragmentation), linked allocation (no external fragmentation but slow random access) and indexed allocation (an index block points to all file blocks, as with inodes in Unix).

Q44. What are the disk scheduling algorithms?

FCFS, SSTF (shortest seek time first), SCAN (elevator), C-SCAN, LOOK and C-LOOK. They decide the order of disk requests to reduce head movement.

Q45. What is RAID?

RAID combines multiple disks for performance and/or reliability: RAID 0 (striping, no redundancy), RAID 1 (mirroring), RAID 5 (striping with distributed parity) and RAID 10 (mirroring plus striping).

Q46. What is the difference between fork() and exec()?

fork() creates a new child process as a copy of the parent. exec() replaces the current process's program with a new program. A shell typically calls fork() and then exec() in the child.

Q47. What is spooling?

Spooling places data for slow devices, such as printers, into a buffer or queue on disk so that the CPU and programs can continue without waiting for the device.

How to Prepare for a Operating System Interview

  1. Know process versus thread: it opens almost every OS interview.
  2. Solve scheduling numericals: FCFS, SJF, Round Robin waiting and turnaround times.
  3. Explain deadlock fully: four conditions, prevention, avoidance and the Banker’s algorithm.
  4. Understand paging and virtual memory: page faults and replacement algorithms.
  5. Use Linux commands: ps, top, kill and free make your answers practical.

Next steps: revise DBMS interview questions and networking interview questions, and see all subjects on our interview questions page.

Want a mentor for your preparation? We teach operating systems, C and core computer science subjects through live online classes arranged around your free time, with mock interviews before your placement. Message us on WhatsApp or email engineersrworld@gmail.com.

More interview preparation: see all interview questions, including Python, SQL, SQL query, Java, JavaScript, React, C++, .NET, Spring Boot, Node.js, DSA, OOPs, DBMS, operating system, networking, machine learning, data science, AI, Excel, Power BI, DevOps, manual testing, Selenium, cyber security and HR.

Frequently Asked Questions

Which OS topics are most asked in interviews?

Process versus thread, process states, CPU scheduling algorithms, deadlock conditions, mutex versus semaphore, paging and virtual memory, and page replacement algorithms.

Are OS questions asked in placement interviews?

Yes. Operating systems is one of the core CS subjects, along with DBMS, computer networks and OOPs, in most campus placement technical rounds.

Do I need to solve scheduling numericals?

Often yes. Practise calculating waiting and turnaround times for FCFS, SJF and Round Robin, and page faults for FIFO and LRU.

How should I prepare for OS interview questions?

Revise the concepts on this page, practise numericals, and connect concepts to real systems, such as checking processes and memory with Linux commands like ps, top and free.

Scroll to Top