Linux Kernel Learning

Source: Internet
Author: User
Linux Kernel learning-general Linux technology-Linux programming and kernel information. For more information, see the following section. Linux architecture
A complete operating system consists of hardware, operating system kernel, operating system services, and user applications. There are two kernel modes: single kernel and micro kernel. Single Kernel, compact structure, fast speed, but not hierarchical. Linux0.11 is a single kernel.

User State-core State
Worker processes running in kernel state cannot be preemptible by other processes, and one process cannot change the status of another process. To avoid kernel data errors during process switching, interruption is prohibited when code in the critical section is executed. The kernel will switch the process only when the process is transferred from the "kernel running state" to "sleep state.

The Linux kernel consists of five modules: process scheduling, memory management, file system, and inter-process communication, network Interface process scheduling controls cpu resources. memory management controls storage resources. All modules depend on process scheduling.

To effectively use the system memory, the memory is divided into different functional areas. The kernel program occupies the starting part of the physical memory.

Directory structure of Linux kernel source code
Boot-> system boot
Fs-> File System
Include
Init
Kenerl/blk_drv, chr_drv, sys
Lib
Mm

Linux uses the intel cpu memory paging Management Mechanism (1 page 4 K physical memory), and uses the ing of virtual linear addresses and actual physical addresses to allow simultaneous programs to use limited memory. In this way, each program in execution can use a much larger address space than the actual memory.

The linux0.11 virtual address space is 4G = 64 M * 64, and each task (process) has 64 M virtual address space, up to 64 tasks.
For each virtual address space, the header is the code area, followed by the data area, and the tail is the stack area.

The boot directory contains three assembly files, which are the first compiled programs in the kernel source file.
The main function is to start the vaginal kernel when the computer is powered on, load the kernel code into the memory, and initialize the system before entering the 32-bit protection mode.
Bootsect. s, setup. s requires as86 for compilation. It uses the as86 assembly language format, head. s requires as compilation, and AT&T for compilation.
Bootsect. s disk boot block program. After compilation, it will reside in the first sector of the disk MBR. After the pc power-on bios self-check, the bios is loaded to the address 0x7c00 for execution.
Setup. s reads the hardware configuration parameters of the machine and moves the kernel module system to the appropriate memory address.
Head. s is compiled and connected to the first part of the system module for hardware testing and initial configuration of memory management.

Fs File System Directory
Contains 17 files, such
Buffer. c processing of memory High-Speed buffer
File_table.c defines the file handle
Ioctrl. c defines the io Control Function
Exec. c exec function Cluster
Fcntl. c file I/o Control
Open. c modify and create a file
Char_dev.c defines the character device read/write function
Pipe. c defines MPs queue reading.
File_dev.c file read/write function
Block_dev.c block read/write
Truncate. c Release the device space occupied by the file when deleting the file
Inode. c I node operation
Bitmap. c I node and Logical Data Block
Super. c super block

The file system program does not directly deal with the driver of the block device, but uses the high-speed buffer.
All accesses to data in the file system must first be read to the high-speed buffer zone.

Main directory of the include header file
The kernel directory contains 12 code files.
Asm. s calls the processing functions of traps. c respectively during the interrupt processing process.
Exit. c process the call to terminate the process
Fork. c uses two c Functions: find_empty_process, copy_process
Mktime. c time function mktime ()
Panic. c displays kernel error information and stops
Printk. c kernel-specific printing function printk
Sched. c SCHEDULING
Signal. c signal Processing
Sys. c many system functions
System_calls.c INT 0x80 system processing
Vsprintf. c string Formatting Function

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.