Interview questions · Book 13
Operating Systems interview questions
146 questions from 37 pages, each with a short answer. Say your answer first, then open the question to check it.
p. 1 · 4 questions
Bootloader
1
What is a bootloader?
A bootloader is a small program that runs after the computer's firmware starts, loads the operating system kernel into memory, and hands control over to it.
2
What is the difference between a bootloader and BIOS or UEFI?
BIOS and UEFI are firmware stored on the motherboard that start the hardware and then launch the bootloader. The bootloader is software on the disk that loads the operating system kernel.
3
What is GRUB?
GRUB, the GRand Unified Bootloader, is the most common bootloader for Linux. It can boot several operating systems and lets you pick a kernel or edit boot options from a menu at startup.
4
What does unlocking the bootloader mean?
On phones and some other devices, the bootloader normally starts only operating systems signed by the manufacturer. Unlocking it removes that restriction so you can install a custom operating system, usually after the device erases its data for security.
p. 2 · 4 questions
Command Line Interface
1
What is a command line interface?
A command line interface (CLI) is a text-based way of using a computer: you type a command with options and arguments, press Enter, and read its output.
2
What is the difference between a CLI and a GUI?
A CLI is operated by typing text commands; a GUI, a graphical user interface, by clicking windows, buttons and menus. CLIs are easier to automate and script, while GUIs are easier to discover for new users.
3
Why do developers use the command line?
It is faster for many tasks, works the same on remote servers, can be scripted and automated, and many developer tools offer their full functionality only through a CLI.
4
What is an exit code?
A number a program returns when it finishes. Zero means success and any other value signals an error, which scripts and CI pipelines check to decide what to do next.
p. 3 · 4 questions
Context Switch
1
What is a context switch?
A context switch is when the operating system saves the state of the running thread or process and restores another one's state so it can use the CPU.
2
Why are context switches expensive?
Saving and loading registers is quick, but the new task finds the CPU caches and address translation buffers filled with the previous task's data. Until they warm up again, memory accesses are much slower.
3
What is the difference between voluntary and involuntary context switches?
A voluntary switch happens when a thread gives up the CPU itself, for example to wait for I/O or a lock. An involuntary switch happens when the scheduler preempts a thread that still wanted to run, usually because its time slice ended.
4
Is switching threads cheaper than switching processes?
Yes. Threads in the same process share one address space, so the kernel does not need to switch page tables, and more of the cached data stays useful.
p. 4 · 4 questions
CPU
1
What is a CPU?
A CPU (central processing unit) is the processor that executes a program's instructions, doing the arithmetic, logic and control work all software runs on.
2
What is the difference between a CPU and a GPU?
A CPU has a few powerful cores designed for varied, sequential work with lots of decisions. A GPU has thousands of simpler cores designed to do the same operation on large amounts of data in parallel, such as graphics or neural network math.
3
What is a CPU core?
An independent processing unit inside the CPU that can run its own stream of instructions. A processor with eight cores can work on eight threads truly at the same time, or more with simultaneous multithreading.
4
What is the difference between x86 and ARM?
They are different instruction set architectures. x86 is used by Intel and AMD in most PCs and servers. ARM designs are licensed to many manufacturers and are known for energy efficiency, which is why they power phones and many newer laptops and servers.
p. 5 · 4 questions
CPU Cache
1
What is a CPU cache?
A CPU cache is a small, very fast memory on the processor that keeps copies of recently used data from RAM, so the CPU spends less time waiting for memory.
2
What is the difference between L1, L2, and L3 cache?
They are levels of cache that trade size for speed. L1 is the smallest and fastest and belongs to one core, L2 is larger and a little slower, and L3 is the largest and slowest cache level, usually shared by all cores.
3
What is a cache miss?
A cache miss happens when the data the CPU needs is not in the cache, so it has to be fetched from a slower cache level or from RAM. Frequent misses can make a program several times slower.
4
Does CPU cache size matter?
It matters for workloads whose active data almost fits in the cache, such as games, databases, and scientific code. A larger cache means fewer trips to RAM, but access patterns in the code often matter more than raw size.
p. 6 · 4 questions
CPU Scheduling
1
What is CPU scheduling?
CPU scheduling is how an operating system decides which ready process or thread runs on each CPU core next, and for how long, so the processor is shared fairly.
2
What is a context switch?
A context switch is when the CPU stops running one thread or process, saves its registers and state, and loads the saved state of another. It lets many tasks share a core, but each switch costs time, so too many switches can hurt performance.
3
What is the difference between preemptive and non-preemptive scheduling?
In preemptive scheduling the operating system can interrupt a running task to give the CPU to another one. In non-preemptive, or cooperative, scheduling a task keeps the CPU until it finishes or voluntarily gives it up.
4
What is round robin scheduling?
Round robin gives each ready task the same small time slice in turn, cycling through the queue repeatedly. It is simple and fair, which makes it a common building block in real schedulers.
p. 7 · 4 questions
Daemon
1
What is a daemon in computing?
A daemon is a program that runs in the background without a user interface, usually started at boot, to provide a service such as logging, scheduling, or SSH.
2
Why is it called a daemon?
The name was coined by programmers at MIT in the 1960s, inspired by Maxwell's demon, an imaginary being in physics that works tirelessly in the background. It has nothing to do with evil spirits.
3
What is the difference between a daemon and a service?
They mean nearly the same thing. Daemon is the traditional Unix term for a background process, while service is the Windows term and is also used for daemons managed by systemd on Linux.
4
What is systemd?
systemd is the init system and service manager used by most Linux distributions. It is the first process started by the kernel, and it starts, supervises, and logs the system's daemons.
p. 8 · 4 questions
Deadlock
1
What is a deadlock?
A deadlock is a situation where two or more threads or processes wait forever for each other to release resources, so none of them can make progress.
2
How do databases handle deadlocks?
Most relational databases detect deadlocks automatically by looking for cycles among waiting transactions. They then abort one of the transactions and return an error, so the application can retry it.
3
How can I prevent deadlocks in my code?
Acquire multiple locks in the same fixed order everywhere, hold locks for as short a time as possible, and use timeouts when acquiring them. Higher-level tools such as queues or immutable data can also reduce the need for locks.
4
What is the difference between a deadlock and a race condition?
In a deadlock, threads block forever waiting for each other, so the program stops making progress. In a race condition, threads access shared data without proper coordination, so the program keeps running but may produce wrong results.