Note: Most of the following are excerpted from the Linux kernel programming primer and the Linux kernel full comment
In the work of this time, found that my Visio drawing familiar with the point, always like what source AH, structure ah and so on as a flowchart to draw to understand, because for the diagram, there is a very intuitive understanding, so the next is also a diagram as the center.
About the Linux kernel architecture
When it comes to operating systems, we all know about the Windows operating system, the Linux operating system, Apple's iOS operating system, the previously burning Symbian operating system, and the recent consumer-electronics very hot Android operating system. A complete operating system is divided into 4 parts.
This can be understood as the cell phone we use. One of the hardware system is what we see the entire cell phone, CPU ah, memory ah, these do not take apart to see, and touch screen ah, keys and so on to see. The OS kernel is what we call Android, but he includes the Linux kernel. Operating system services is a set of Android structure, give us the intuitive is that a bit of a dazzling interface. We can click to achieve the function we want. User application is that we often play QQ Ah, navigation ah, of course, all kinds of fun games, Angry Birds, graffiti jump, Fruit Ninja, is not want to play a? Alas, study well, although the cell phone is right next to it.
For Linux kernel single kernel mode system, there can be divided into the following:
The Linux kernel can also be divided into 5 large modules.
Its relationship and main functions can be seen in:
About Linux Memory
Physical memory can be divided into the following:
The kernel occupies the first part of the memory; the next is the high-speed buffer portion of the disk used by the disk, which deducts the video memory and bios from 640k to 1m, then the virtual disk, and the last part is the main memory area available to all programs.
In Linux memory management, segment transformation: Converts a logical address consisting of segment selectors and intra-segment offsets to a linear address. Page Transform: Converts a linear address to the corresponding physical address. This is shown in detail:
Virtual address: Refers to the address generated by the program by the segment selector and the offset address two parts within the paragraph. Why call it a virtual address? Because these two-part addresses do not have direct access to physical memory, they are processed or mapped by the transform mechanism of the segmented address to correspond to the corresponding physical memory address.
Segment Descriptor: Provides the CPU with the information necessary to map a logical address to a linear address. Descriptors are created by the program compiler, linker, loader, or operating system.
Descriptor table: There are two types of save descriptors in descriptor tables
1. Global Descriptor Table---GDT)
2, Local Descriptor Table (Local descriptor---LDT)
A descriptor descriptor is an array of memory that consists of 8-byte descriptor items. The processor uses the GDT and LDTR registers to locate the GDT table and the current LDT table. Can contain up to 8192 (2^13) descriptors.
Selector: The selection part of a logical address that specifies a descriptor, which is accomplished by specifying a descriptor and indexing one of the descriptor entries.
Segment Register: The processor saves the information in the descriptor in the segment register, thus avoiding querying the descriptor table each time the memory is accessed.
Linear address: indirectly points to the corresponding physical address by specifying a page table, a page in the page table, and an offset value in the page.
Page table: An array of simple 32-bit page indicators. The page table itself is also a page of memory, so it contains 4K bytes of memory that can hold 1K 32-bit items.
Offset = 2^12=4k, table =2^10, directory = 2^10, so the linear address space is 2^10*2^10*4k=4g.
Since the 0.11 kernel defines the maximum available virtual memory space for each process as 64M, the logical address of each process can be converted to the address of the linear space by *64m the task number.
About the Linux process
The process can run in the kernel State or user state, when the resource is available to be awakened, into the ready state, when the process is in an interruptible state of sleep, the received signal can be awakened, when in a non-interruptible sleep state, can only be used wakeup, etc. when the process is in a paused state, The signal can be sent to the ready state; When the zombie state is stopped, the parent process has not called the wait query state, and once the parent process has called wait to get the child process information, the process task data structure is freed.
About the Linux file system and source directory
About the Linux kernel makefile
The Linux makefile file is a parameter configuration file for compiling the accessibility software make. The main purpose of the Make tool software is to automatically determine which files need to be recompiled in a program system that contains multiple source program files by identifying which files have been modified.
The main function of the makefile here is to instruct the make program to connect and merge all kernel-compiled code into a running kernel image file using the build executor in the tools/directory, which is independently compiled and connected. Specifically, the BOOTSECT.S, SETUP.S in the boot/directory are compiled using the 8086 assembler, generating their own execution modules respectively. All other programs in the source code are compiled with the GNU compiler Gcc/gas and connected to the module system. Then use the build tool to combine the three blocks into a kernel image file image.
Learn the basics of Linux kernel source preparation with the rookie