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.
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.
How does the interaction happen?
Ever so often the user mode program needs to access a privileged resource and that happens via system calls.
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.