"Linux kernel design and implementation" notes--kernel compilation process and kernel programming features __HTML5

Source: Internet
Author: User
Tags inotify system log
the process of kernel compilation

1. Download Kernel source code tree extract to/usr/src
# Tar XF linux-3.13.5.tar.xz-c/usr/src
# Ln-sv/usr/src/linux-3.13.5/usr/src/linux
2. The kernel configuration profile is stored in the kernel source root directory in the. config file
Make Oldconfig back up the current. config file to. config.old
Make config is configured at the command line
Make Menuconfig configuration in graphical interface
Make Defconfig creates a configuration based on the architecture used by the default configuration
3. Compiling the kernel
make or Make-jn derivative n compile tasks to compile
Make >/dev/null redirects output
4. Installation Module
Make Modules_install
Install the compiled module to the correct home directory/lib/modules
5. Compile and install make install
Vmlinuz-ver is generated in the/boot/directory,
System.map-ver (symbol table, corresponding to the kernel symbol and address)
The/boot/grub/grub.conf file will add a startup entry for the new kernel
6. Restart, select a new kernel can be kernel programming features: no libc or standard header files.

Basic header File/include
such as #include<linux/inotify.h>, located in/include/linux/inotify
Architecture-Related header file/arch/<architecture>/include/asm
such as #include<asm/ioctl.h> in/arch/x86/include/asm/ioctl.h

Most function implementations in LIBC call system call, application from user space into kernel space through system call, if the function in the LIBC library is called from the kernel, it may occur from "kernel into kernel", which may cause the system instability, crash and other potential problems. No memory protection

Memory errors in the kernel can cause oops, and kernel memory is not paged. Floating point numbers are not easy to use

Executing floating-point instructions requires capturing traps, starting integers to floating-point conversions, and cumbersome
Low capacity and fixed kernel stack synchronization and concurrency

The kernel is prone to competitive conditions, and Linux is a preemptive multitasking system, supporting SMP, two processors executing code at the same time, using the same resource; interrupt arrival is more important than asynchronous portability

1, Word length and data type
2, data alignment
3, byte order
4, time, page length
5, processor sequencing, SMP, kernel preemption, high-end memory, and other considerations.
using GNU C

Uses a number of GNU C compiler features, inline assembly, inline function, branch declarations, etc. 18th debugging

1, Print debug PRINTK () 18 levels
Klogd obtain kernel information from the record buffer and save it to the system log file through SYSLOGD. The
2, OOPS
OOPS is the most common way for the kernel to inform users of the unfortunate occurrence, which can occur because of the memory access bounds, illegal instructions, and so on, OOPS the function call chain that can cause the error to occur retrospectively.
3, detection system
uses UID as the selection condition
if (current->uid!= 7777)
{/* Original code/}
Else {/* new attribute/}
Use conditional variable set some condition variables to control whether the kernel executes a piece of code.
using statistics
to implement the idea is to set up a global variable in the kernel, such as My_count, when the kernel executes to a piece of code, give My_count + 1 on the line. Also print my_count (can be used PRINTK), easy to see its value at any time .
Use frequency limits (limit the number of error outputs)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.