1. What is an operating system and why do we need one?
An operating system is a program that manages a computer’s hardware and provides a basis for application programs. It is the first software loaded after the bootloader and the part that stays in memory at all times — the kernel — controls the machine from then on.
We need an OS because raw hardware is unusable on its own. Without one, every program would have to track its own disk sectors, manage physical memory addresses, and schedule its own CPU time — and programs would collide. The OS sits between applications and hardware as a resource manager and an extended machine, giving each program a safe, simple interface to the underlying hardware.
It is also the only software that arbitrates access: the OS decides which process gets the CPU, how much memory each can use, and which can write to disk. Without this mediation, one faulty program could corrupt another or crash the whole system.
2. What is the process view of an OS?
The process view sees the OS as a manager of processes — programs in execution. In this view the OS is responsible for the entire lifecycle: creation (via fork() and exec()), scheduling (deciding which process runs on the CPU next), synchronization (coordinating access to shared resources so race conditions don’t corrupt data), and communication (letting processes exchange data via pipes, shared memory, or messages).
The process abstraction gives each program the illusion that it owns the machine: every process thinks it has its own CPU and its own memory. The OS maintains a Process Control Block for each process to track its state, registers, and resources so it can suspend one process and resume another cleanly.
3. What is the resource manager view of an OS?
The resource manager view sees the OS as a central allocator that hands out limited hardware resources to competing programs. Every request for CPU, memory, or I/O goes through the OS, which decides who gets what, when, and how much.
This view has three jobs. Multiplexing — sharing one CPU among many processes through scheduling so none is blocked by the others. Protection — preventing one process from reading or corrupting another process’s memory. Virtualization — giving each process the illusion of a dedicated machine even though it shares the physical hardware. Without this management, programs would interfere with each other and the system would crash.
4. What are the main services an OS provides?
The core OS services are:
- Program execution — load a program into memory, run it, and handle its termination.
- I/O operations — provide a uniform interface for reading and writing devices.
- File system — create, delete, read, write, and organize files.
- Communication — inter-process communication via pipes, shared memory, and messages.
- Error detection — detect hardware failures and software bugs and handle them gracefully.
- Resource allocation — CPU scheduling, memory allocation, and device assignment.
- Protection — ensure one process can’t corrupt another or the OS itself.
- Accounting — track resource usage for billing or optimization.
In an interview, the three that come up most are process management (create, schedule, terminate processes), memory management (allocate, track, protect memory), and I/O management (coordinate with external devices).
5. What is the difference between a program and a process?
A program is a passive set of instructions stored on disk — it is a file, it occupies space, and it does nothing until it runs. A process is an active entity: the program loaded into memory and executing on the CPU, with a program counter, stack, data section, and resources like file handles.
A program can spawn many processes — opening three Chrome tabs creates three processes from one executable. A process is dynamic and transient: it is created, runs, and terminates, while the program on disk persists until deleted. The key distinction for an interview: a program is static and passive; a process is the live instance of it in memory.
6. What are the types of operating systems?
Operating systems are categorized by how they handle users and jobs:
- Batch OS — jobs with similar requirements are grouped into batches and run without user interaction. High throughput for repetitive tasks like payroll and billing, but no interactivity and painful debugging.
- Time-sharing (multitasking) OS — the CPU switches between users/tasks so rapidly each feels they have the machine alone. Round-robin scheduling gives each user a time slice; interactivity and response time are the key metrics.
- Distributed OS — multiple independent computers are managed as a single system, sharing resources across the network. Offers resource sharing, fault tolerance, and scalability, at the cost of network latency and partial-failure complexity.
- Real-Time OS (RTOS) — used where operations must complete within strict time constraints, like car airbags or video streaming.
7. What is the difference between a batch OS and a time-sharing OS?
Batch OS groups jobs into batches and runs them with no user interaction — throughput is king, and the machine churns through jobs like payroll or log processing. Time-sharing OS gives each user a slice of CPU time in rapid rotation — interactivity and response time matter most.
Batch is “fire and forget”: you submit the job and pick up the result later. Time-sharing enables interactive computing — editors, terminals, anything where the user waits on the machine. Batch leaves the CPU idle while a job waits for I/O; time-sharing hides that idle time by switching to another task. The trade-off is that batch maximizes utilization on expensive mainframes, while time-sharing optimizes user experience.
8. What is the difference between a hard and a soft real-time system?
Hard real-time systems guarantee that deadlines are met absolutely — missing one is a catastrophic system failure. Examples are car airbag deployment and flight control, where a late response means physical harm. Hard RTOS uses deterministic, predictable scheduling and runs on systems like QNX and VxWorks.
Soft real-time systems treat deadlines as important but not critical — missing one degrades quality but doesn’t crash the system. Examples are video streaming and online gaming, where a late frame just causes a stutter. Soft RTOS uses priority-based scheduling and typically runs on Linux with PREEMPT_RT.
9. What is a distributed OS and why would you use one?
A distributed OS makes a cluster of independent computers appear as a single system to the user. The physical machines are separate, but the OS manages them as one resource pool — CPU, memory, and storage are shared across the network.
You use one for resource sharing (distributed databases that pool storage), reliability (redundant nodes that keep the system up if one fails), and scalability (adding more machines as load grows). The costs are network latency, the complexity of partial failures — some nodes crash while others keep running — and a larger security surface.
10. What is multitasking in the context of an OS?
Multitasking allows multiple tasks to share a single CPU. When one task waits for I/O — a disk read, a network response — the CPU immediately switches to another ready task instead of sitting idle.
This keeps the CPU busy and makes efficient use of the processor: instead of one program at a time, many programs make progress in interleaved bursts. Multitasking is the foundation of time-sharing systems, and it is what lets a user run a browser, an editor, and a music player simultaneously on one machine.
11. What is a monolithic kernel and what are its trade-offs?
A monolithic kernel puts everything — device drivers, the file system, networking, and scheduling — in kernel space. Because the components communicate through direct function calls rather than message passing, it is fast and efficient.
The trade-off is stability: one buggy driver runs with full privileges, so a single driver crash can bring down the whole kernel in a panic. Monolithic kernels are also large. Linux is the canonical example — it is technically a hybrid kernel because it supports loadable kernel modules, but its design is monolithic for performance.
12. What is a microkernel and what are its trade-offs?
A microkernel keeps only the essentials in kernel space — IPC, scheduling, and basic memory management. Everything else, like drivers and the file system, runs as servers in user space and talks to the kernel through message passing.
The trade-off is reversed from the monolithic kernel: because each server is isolated in user space, a crashing server can be restarted independently without taking down the system — much better stability. But the IPC overhead makes it slower, since every request crosses the user/kernel boundary. Minix, QNX, and L4 are microkernels; QNX’s reliability is why it runs in cars and medical devices.
13. What is user mode vs kernel mode (dual mode)?
Modern CPUs support at least two privilege levels. User mode (ring 3) is where applications run — they have a restricted instruction set and can only access their own memory. Kernel mode (ring 0) is where the OS runs — it can execute any instruction, access any memory, and control hardware directly.
A mode bit in the CPU (0 = kernel, 1 = user) tracks the current mode. The separation is enforced by hardware, not just the OS. If a user-mode program attempts a privileged instruction — like modifying page table registers or disabling interrupts — the CPU raises a general protection fault and the OS typically terminates the program. This dual-mode design is the foundation of OS security and stability.
14. What is a system call and how does the flow work?
A system call is the API between a user program and the kernel — how a user-mode program requests a privileged service like reading a file, creating a process, or sending data over a network.
The flow: an application calls a library function like read(fd, buf, count). The library pushes the syscall number and arguments into registers. A trap (or syscall) instruction atomically switches the CPU to kernel mode — saving the return address and state — and jumps to the kernel’s syscall handler. The kernel validates the arguments, performs the request through the device driver, returns the data, and switches back to user mode.
15. What is the difference between fork() and exec()?
fork() creates an identical copy of the calling process. The child gets a new PID and inherits the parent’s memory, file descriptors, and environment — in modern systems with copy-on-write so memory isn’t actually copied until one of them writes. exec() replaces the current process image with a completely new program — the PID stays the same but the memory image is entirely new.
The typical pattern is a shell calling fork() to create a child, then the child calling exec() to run a command like ls. So fork duplicates the process; exec swaps what the process is running.
16. How do read() and write() system calls work?
Both operate on file descriptors. read(fd, buf, count) copies data from a file or device into a memory buffer; write(fd, buf, count) copies data from the buffer to the file or device. The file descriptor identifies the open file, socket, or pipe.
Both are usually blocking — the process sleeps until the operation completes. The kernel does the actual I/O in kernel mode, so the application never touches the hardware directly. These two calls sit at the heart of the Unix “everything is a file” philosophy, since sockets, pipes, and devices all expose the same read/write interface.
17. What is the difference between multiprogramming, multitasking, and multiprocessing?
Three terms that sound alike but describe different things:
- Multiprogramming — keeps multiple programs in memory simultaneously. When one program waits for I/O, the CPU switches to another ready program, so the CPU never idles. Boosts CPU utilization; assumes no user interaction (the classic batch-era technique).
- Multitasking (time-sharing) — rapid switching of the CPU between tasks so that to a user every task appears to run at once. This is multiprogramming with a time quantum and interactive users: each task gets a short time slice.
- Multiprocessing — actually executing on multiple physical CPUs/cores at the same time, so multiple processes genuinely run in parallel. Requires multiple processors; the others do not.
| Term | What’s multiple | Key idea |
|---|---|---|
| Multiprogramming | Programs in memory | Keep the CPU busy while one waits for I/O |
| Multitasking | Tasks sharing one CPU | Fast time-slicing = interactive, responsive |
| Multiprocessing | Physical CPUs/cores | True parallel execution |
The quick interview one-liner: multiprogramming keeps many jobs loaded to keep the CPU busy; multitasking switches between them fast enough to feel simultaneous; multiprocessing runs them on separate hardware.
18. What happens during the system boot process?
Boot is the sequence that loads the OS from disk into memory and hands control to it:
- Power-on / BIOS/UEFI — the machine runs firmware (BIOS or UEFI). It does a Power-On Self-Test (POST), initializes hardware, and locates a bootable device.
- Bootloader — UEFI/BIOS loads a small program, the bootloader (GRUB, LILO), which presents a menu and then loads the kernel into memory.
- Kernel initialization — the kernel decompresses itself, sets up memory management (page tables), initializes CPU, interrupts, the scheduler, and core subsystems. It mounts the root file system.
- init/systemd (PID 1) — the kernel spawns the first user-space process, PID 1. This is
systemdon modern Linux,initon older systems. It reads configuration, starts services and daemons, and brings the system to its run level / target. - Login — once services are up, a login prompt or desktop environment starts, and the system is usable.
The memorable chain for an interview: BIOS/UEFI → bootloader → kernel → init (PID 1) → services → login. The kernel is the same code every time; the bootloader’s job is simply to find and launch it.
Premium Content
Unlock OS Introduction, Types & Kernels and all premium lessons with a subscription.
From ₹199.99/year — See plans