User Space Vs. Kernel Space in Linux

Beaglebone black board






In this article, we will explain the difference between the user space and the kernel space in the linux operating system.

When an operating system like linux is used, the code which runs on the CPU can be segregrated as user space code or kernel space code.

This is shown in the diagram below.


User space vs. kernel space in linux


When the kernel space code runs on the CPU, the operation mode of the CPU will be in privileged mode. This means that the kernel level code can access many of the restricted resources of the system, such as memory, peripherals, processor instructions, control settings of the processor, etc.

In comparison, the user space code will operate in restricted mode or non-privileged mode. The user space code cannot access memory locations or any specific kernel-level functions. User space can be seen as the more basic, non-privileged setting that access user programs.

So user space is code that can access any user-level program.

Kernel space is code that can access any user-level program, as well as linux schedulers, device drivers, subsystems, etc.

Kernel space can be seen as a higher-level supervisor access than the user space, kind of like the difference between a regular user and an administrator.

An important thing to know is that if any user space program wants any services to use any various memories, device drivers, or peripherals, it can request kernel level access using system calls. System call handlers are kernel level code (so it runs in privileged mode) to fulfill the user space request.

So this sums up user space vs kernel space code in operating systems such as linux.



Related Resources





HTML Comment Box is loading comments...