Linux Kernel vs User Space – A Beginner’s Perspective

linux kernalThe Linux Kernel and User Space represent two distinct environments within the operating system, with the kernel acting as the core and User Space as the space where user applications and processes reside.The kernel has privileged access to system resources and manages the hardware, while user space applications operate with restricted access and interact with the kernel through system calls. 

Displaying

Privileges

Kernel space has privileged access to system resources while user space has restricted access to the system resources.

Location

Kernel space has the highest memory space while user space has the lowest memory space.

Purpose

Kernel space does core system operations and hardware management whereas user space is used for running user based applications and processes.

Interaction

Kernel space directly manages hardware whereas user space interacts with kernel through system calls.

Analogy

  • The kernel is like the building’s foundation and essential infrastructure (e.g., electricity, water, plumbing). It’s the core part that everything else depends on, and it needs special permissions to manage everything.
  • The user space is like the apartments or offices within the building. Each apartment has its own space and can’t directly access the building’s foundation or utilities, but they can make requests to the building’s management (the kernel) to get things done via phone calls (system calls).

The examples are : 

Kernel mode system calls

  • read(), write(), fork(), exec(), open(), close()

User mode system C functions

  • printf(), scanf(), strlen(), strcpy(), sort()

The modern approach is to ensure that the operating system uses privilege instructions to completely control the system. Processors that support operational modes were designed specifically for this.

Kernel mode “Priviledge mode”

In this mode, the kernel can interact with the I/O devices like Network card, graphics card,hard drives and peripherals. The CPU runs in kernel mode .When it comes to the Memory component, privilege instructions allow the manipulation of a special hardware component called MMU.

System Calls in kernel mode are incredibly useful as they can handle hardware interaction for us.

Driver software is also developed with privilege mode and runs in the kernel mode.

User mode “Restricted mode”

The above example can’t be handled by the program running in user mode. In this mode user programs are allowed to use a wide variety of instructions like 

  • Move data
  • Copy data
  • Executing arithmetic, floating & bitwise operations
  • Evaluating conditions and running loops 

Different types of kernel

UNIX uses Unix kernel 

Windows uses Windows NT kernel 

Linux uses Monolithic kernel

MAC uses Darwin kernel

Avatar photo

Technical Lead
Susmita is focused on delivering effective training to the learners in front-end RTL design and Design for Testability and she writes articles that help our readers gain good knowledge on such VLSI topics.
Whatsapp