Basic preparation of linux kernel source code

During this period of work, I found that my visio drawing is a little familiar, and I always like to understand the source code, structure, etc. as a flowchart, because I have a very intuitive understanding of the diagram, so The next step is to focus on the image.

 

About linux kernel architecture

       When it comes to operating systems, we all know the windows operating system, the linux operating system, Apple's ios operating system, the Symbian operating system that used to be very popular, and the android operating system that has recently become very popular in consumer electronics. A complete operating system is divided into 4 parts.


       Think of this as the cell phone we use. Among them, the hardware system is the entire mobile phone we see, cpu, memory, which cannot be seen without disassembling, and touch screen, buttons and the like. The operating system kernel is what we call android, but it includes the linux kernel. The operating system service is a set of structure of android, which gives us the intuitive interface that is a bit dazzling. We can achieve the function we want by clicking. The user application is the QQ we often play, navigation, of course, all kinds of fun games, Angry Birds, Doodle Jump, Fruit Ninja, do you want to play again? Alas, let's study hard, even though the phone is next to me.

For the single-kernel mode system of the linux kernel, it can be divided into the following:


       The Linux kernel can be divided into 5 large modules.

Its relationship and main functions can be seen in the following figure:



About linux memory

Physical memory can be divided into the following figure:

The kernel occupies the beginning of the memory; the next is the common hard disk, the high-speed buffer part used by the floppy disk, which deducts the 640k to 1m of the video memory and bios; then the virtual disk; the last part is the main memory area that can be used by all programs.


In Linux memory management, segment transformation: converts a logical address composed of a segment selector and an offset within the segment into a linear address. Page translation: Convert linear addresses to corresponding physical addresses. Specifically, it can be seen in the following figure:


Virtual address: refers to the address generated by the program, which consists of two parts: the segment selector and the offset address in the segment. Why call it a virtual address? Because the address composed of these two parts does not directly access the physical memory, but must be processed or mapped by the segment address conversion mechanism before corresponding to the corresponding physical memory address.

       Segment Descriptor: Provides the CPU with the necessary information to map logical addresses to linear addresses. Descriptors are created by the program compiler, linker, loader, or operating system.

       Descriptor table: There are two types of descriptors stored in the descriptor table

1. Global descriptor table (Global descriptor table---GDT)

2. Local descriptor table (Local descriptor table---LDT)

The descriptor table is an array of 8-byte descriptor entries in memory. The processor locates the GDT table and the current LDT table by using the GDT and LDTR registers. It can contain up to 8192 (2^13) descriptors.

Selector: The selection part of the logical address used to specify a descriptor, which is accomplished by specifying a descriptor table and indexing one of the descriptor entries.

Segment registers: The processor stores the information in the descriptors in segment registers, thus avoiding the need to consult the descriptor table each time memory is accessed.

 

 

 

Linear address: Indirectly point 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 pointers. The page table itself is also a page of memory, so it contains 4K bytes of memory and can hold 1K 32-bit entries.

 

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 of each process as 64M, the logical address of each process can be converted to the address of the linear space by using the task number * 64M.

 

 

About the linux process

       The process can run in kernel mode or user mode, wake up when resources are available, and enter the ready state; when the process is in an interruptible sleep state, it can be woken up by a signal; when it is in an uninterruptible sleep state, it can only be used wakeup, etc. Wake up; when the process is in a suspended state, a signal can be sent to make it enter the ready state; when it is in a dead state, when it has stopped running, the parent process has not called wait to query the state, once the parent process calls wait to obtain the child process information, the process task The data structure will be freed.

 

 


About the linux file system and source directory

 

 

 

 

 


 

 

 

 

 

 

 

 

 

 

 

 





About linux kernel makefile

Linux makefile文件是编译辅助工具软件make的参数配置文件。Make工具软件的主要用途是通过识别哪些文件已经被修改过,从而自动地决定在一个含有多个源程序文件的程序系统中哪些文件需要被重新编译。


       这里的makefile主要作用是指示make程序最终使用独立编译连接成的tools/目录中的build执行程序将所有内核编译代码连接和合并成一个可运行的内核映像文件image。具体是对boot/目录中的bootsect.s、setup.s使用8086汇编器进行编译,分别生成各自的执行模块。再对源代码中的其他所有程序使用GNU的编译器gcc/gas进行编译,并连接成模块system。再用build工具将这三块组合成一个内核映像文件image。

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325997741&siteId=291194637