ch1. Introduction To The Linux Kernel
ch1. Introduction To The Linux Kernel
國立中正大學
資訊工程研究所
羅習五 老師
GNU/Linux
• One of Linux's most interesting features is that
it is not a commercial product
• The basics of a Linux system are the kernel, C
library, compiler, toolchain, and basic system
utilities, such as a login process and shell.
• Strictly speaking, after all, the term Linux
refers to only the kernel.
Kernel components
• Typical components of a kernel are
– interrupt handlers to service interrupt requests,
– a scheduler to share processor time among
multiple processes,
– a memory management system to manage
process address spaces, and
– system services such as networking and
interprocess communication (IPC).
Kernel mode and kernel space
• The kernel includes a protected memory space
and full access to the hardware.
• This system state and memory space is
collectively referred to as kernel-space
• A user process executes in
– User-space
– kernel-space
Function calls and OS
• Eventually call a system call
– eventually calls write() to write the data to the
console
• Always call a system call
– some library calls have a one-to-one relationship
with the kernel.
• Other C library functions
– such as strcpy(), should (you hope) make no use of
the kernel at all.
Devices and OS
• When hardware wants to communicate with
the system, it issues an interrupt that
asynchronously interrupts the kernel.
– Interrupts are identified by a number.
– The number is used to identify a interrupt handler
• Linux’s interrupt handlers do not run in a
process context. Instead, they run in a special
interrupt context that is not associated with
any process.
The modes a CPU executes in
• In kernel-space, in process context, executing
on behalf of a specific process
• In kernel-space, in interrupt context, not
associated with a process, handling an
interrupt
• In user-space, executing user code in a process
The modes a CPU executes in
User space
Process context
Kernel space
(including
bottom half)
CTX
ISR
Top halve
Linux Versus Classic Unix Kernels
• Linux supports the dynamic loading of kernel
modules.
• Linux has symmetrical multiprocessor (SMP)
support.
– Including UMA and NUMA
• The Linux kernel is preemptive
• Linux does not differentiate between threads
and processes.
– by invoking “clone()”
Note: A preemptive kernel