↓ Skip to main content
Linux

Kernel Mode

·2 mins

The CPU operates in two modes in Linux

  1. User mode (non privileged mode)
  2. Kernel mode (System mode)

When operating in Kernel mode it has un-restricted access to resources like memory and input output devices.

Kernel is a trusted software and all other programs are treated as untrusted softwares.

Mode switch
#

All processes start execution in the user mode, and they switch to kernel mode only when obtaining a service provided by the kernel. This change in mode is termed a mode switch.

A system call, sometimes referred to as a kernel call — system call

How does the interaction happen?
#

Ever so often the user mode program needs to access a privileged resource and that happens via system calls.

A system call is a request to the kernel by an active process for a service performed by the kernel.

When a user process runs a portion of the kernel code via a system call, the process temporarily shifts into the kernel mode.

Preemptive vs non-preemptive
#

A preemptive task can be interrupted before it completes its function whereas a non preemptive task cannot be interrupted before it completes its task.

Process in kernel mode can be interrupted by an interrupt or an exception.

A process in kernel mode cannot be arbitrarily suspended and replaced by another process for the duration of its time slice — Preempted
Author
Samarthya
Engineer, learner, tinkerer. This is my trophy shelf of everyday work and leisure.

Related

Linux Utils

·5 mins
Ping # I have used ping often but never to an extend that I could understand the complete range of options and power available at hand.

SYSTEMD: Mother of all processes

·4 mins
systemd is the replacement system for System V and with the primary goal of starting services in parallel. Remember init levels? GRUB: Grand Unified Boot Loader — /boot/grub/grub.conf Some key points