User Space vs Kernel Space, How System Calls Execute, and the x86 Boot Sequence
Company: Canonical
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Technical Screen
Three operating system questions: what separates user space from kernel space, what a system call is and how one executes, and how an x86 machine boots from power-on to a running system.
### Clarifying Questions
- Should the system call answer use x86-64 Linux as the concrete example?
- Should the boot sequence cover legacy BIOS, UEFI, or both?
### Part 1 — User space versus kernel space
What is the difference between user space and kernel space? What enforces the boundary, and why does it exist?
```hint What the CPU enforces
Think about what the processor itself checks, not only how memory is laid out: what stops an ordinary program from writing to a device or to another process's memory?
```
#### What This Part Should Cover
- CPU privilege levels and privileged instructions
- Page-table protection of kernel memory and separate per-process address spaces
- The ways execution crosses the boundary, and what crossing costs
### Part 2 — System calls
What is a system call? Walk through what happens when a program makes one, and explain in which process the kernel code for a system call runs.
```hint Follow one call
Trace a single read() from the C library into the kernel and back. Which instruction changes the privilege level, and whose stack and address space are in use while the kernel does the work?
```
#### What This Part Should Cover
- A definition with examples
- The mechanics of entry, dispatch, argument checking and return, including how errors are reported
- The process context in which the kernel executes the call, and what that allows (sleeping, access to the caller's memory)
### Part 3 — The x86 boot sequence
What happens, in order, from the moment an x86 machine is powered on until the operating system is running?
```hint The first instruction
Start where the CPU fetches its very first instruction, and ask what must already be in memory before the kernel can run at all.
```
#### What This Part Should Cover
- The reset vector and firmware initialization
- The legacy BIOS path versus the UEFI path to a bootloader
- The kernel's own start-up, the initial RAM filesystem and the first user-space process
### What a Strong Answer Covers
- Hardware enforcement as the basis of the boundary, not convention
- A precise system call path with real instructions or registers for one architecture
- The distinction between a separate process and kernel code running on behalf of the caller
- A boot sequence in the correct order, with the hand-off at each stage
- Concrete tools or observations (strace, dmesg, the vDSO) that tie the explanation to practice
### Follow-up Questions
- Why is clock_gettime usually much cheaper than other system calls on Linux?
- What happens when a user program dereferences a kernel address?
- Where does Secure Boot fit into the UEFI boot chain, and what does it verify?
- How does a context switch differ from a switch between user mode and kernel mode?
Overview: An operating systems interview question set covering what separates user space from kernel space, how a system call executes and in which process it runs, and the x86 boot sequence from the reset vector through firmware, bootloader, kernel and init. It tests hardware-level understanding of privilege and system start-up.
Read the full Canonical Software Engineer interview experience this question came from