Chapter One Linux kernel Introduction I. Unix
UNIX is a powerful, robust, and stable operating system.
unix--supports preemptive multitasking, multi-threading. Virtual memory, page breaks, dynamic links, and TCP/IP networks.
Ii. Introduction to operating system and kernel
operating systems are those parts of the entire system that are responsible for the most basic functions and systems management.
The kernel is isolated from normal applications, is generally system-state, has a protected memory space, and has all the permissions to access hardware devices.
This system state and the protected memory space, collectively known as the kernel space .
Applications running in the system communicate with the kernel through system calls .
The basic behavior of the application to complete its work is:
The application is trapped in the kernel through the system call interface.
The activity of the processor must be one of the following three:
- Run in user space, execute user process
- Runs in kernel space, is in the process context, executes on behalf of a particular process
- Runs in kernel space, is in the interrupt context, is independent of any process, and handles a specific interrupt
Chapter two from the kernel one, to obtain the kernel source code
Use Git to get the source code:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.gitgit pull # 更新分支到Linux的最新分支
Installation decompression:
tar xvjf linux-x.y.z.tar.bz2或者tar xvzf linux-x.y.z.tar.gz
Patching:
patch -p1 < ../patch-x.y.z
Second, compile the kernel 1. Configuring the Kernel
Command-line tools for character pages:
make config
Graphical interface Tools
make menuconfig
A few other configurations:
make defconfig //基于默认配置make oldconfig //验证和更新配置
2. Compiling the kernel
make
Reduce compiled spam-redirects the output.
# 重定向到这个文件里了make > /dev/null # 把无用的输出信息重定向到永无返回值的黑洞里。
3. Install the new kernel
make modules_install
System.map This file is a symbol comparison table
Three, the characteristics of the core development
- Kernel development can neither access C library nor access standard C header files
Response: The Include/linux folder contains the required kernel header files.
- The kernel programming must use the GNU C
- Kernel programming lacks a memory protection mechanism like user space
The memory in the kernel is not paged.
- Difficult to perform floating-point arithmetic during kernel programming
- The kernel gives each process only a small fixed-length stack
- Because the kernel supports asynchronous interrupts, preemption, and SMP, you must always be aware of synchronization and concurrency
SMP: Symmetric multi-processing system.
Common ways to solve competition: spin locks and semaphores .
- To consider the importance of portability
such as keeping the byte order, 64 bits to it, not assuming word length and page lengths.
Reference: http://www.cnblogs.com/20135202yjx/p/5272633.html
20135302 Wei Quiet--textbook 1-2 study notes