Kernel Mode
The CPU operates in two modes in Linux
- User mode (non privileged mode)
- 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