Level 0 · Module 2

Kernel vs user space

Learn why operating systems separate privileged kernel code from ordinary applications.

Difficulty
beginner
Time
9 min read
Prerequisites
What an OS does
Reading progress0% read

Not completed

By the end, you can

  • Distinguish kernel space from user space.
  • Explain why applications have restricted hardware access.
  • Describe a system call as a controlled request to the kernel.

Summary

The kernel is the privileged core of an operating system. Applications usually run in user space with fewer permissions and use system calls to request kernel services.

Introduction

A bug in one notes app should not be allowed to overwrite another app’s memory or reconfigure the disk. Operating systems limit that damage by separating ordinary code from trusted kernel code.

Explanation

Kernel space can perform privileged operations such as controlling devices, managing page tables, and scheduling processes. User space contains applications and many supporting services. A user-space program crosses the boundary through a defined system call. The kernel validates the request, performs allowed work, and returns a result.

Real-world example

Opening a file

A text editor cannot simply read any disk location. It asks the kernel to open a named file. The kernel checks the process’s permissions and the file system, then returns a handle or an error.

Cross the protected boundary

system-call-flow.txttext
USER SPACE
text editor → request: open("notes.txt")
---------------- system-call boundary ----------------
KERNEL SPACE
check permission → ask file system → return result

Code example

request-result.txttext
request: open notes.txt for reading
result:  file handle 7

request: open private.txt for reading
result: permission denied

Common mistakes

  • Calling the entire operating system “the kernel.”
  • Assuming user-space programs can freely access physical memory or devices.
  • Treating a system call as proof that every request will be allowed.

Quiz

Knowledge check

Why does an application use a system call to read a file?

Try it

Trace a protected action

Describe the user-space request and two kernel checks that might occur when an app uses a camera.

Key takeaways

  • Kernel space holds privileged OS code; applications generally run in user space.
  • The separation limits damage and protects shared resources.
  • System calls are controlled requests across the boundary.
View module overview