Read nuclear diary (4)

xiaoxiao2021-03-06  122

This article comes from: http: //os.silversand.net Author: sunmoon (2001-09-01 07:05:00)

These days are not very good, progress is unhappy. Sometimes I suddenly discovered in the gap of the desperate reading code, stop for a while, the harvest is bigger. Especially for this very large system. Grasping the whole It is especially important. With the overall dismantling of Linux, I have never want to start so vague. It seems that I have already spent the extreme. But I should be prepared because I interpret the whole detail. At the time, there will be the same experience. The reason why the entire Linux kernel is hard, it is in its overallity. Think about whether we write a lot of people in the program, it is like a huge meat ball. Let you don't know how to blame. But one but bite. It is very fragrant. After all, I read such a good code is also a kind of enjoyment. I personally think Linux's kernel is difficult in these points: 1, the system is huge, too Many variables, structures, and Typedef definitions are not easy to find .2, as an operating system, when it is called, it is called, and you don't understand a lot of Makefile. You don't know how this 50 m is organized. Moreover, you can never use Debug as a tracker .3, a huge data structure, it may be relatively simple to make it easy to read. Therefore, in the primary stage of reading. We should be good at imagination, good at not Easy to understand the partial understanding of pseudo code, when we grasp the overall situation, the whole structure is dismantled, and it is not too late. Moreover, although the core itself, the computation, structure it involves it. Essentially and the courses have no difference. (Unfortunately I am not a computer system graduation). Just, it's more. For example, the process schedules this part, that is, when calling fork (), Task_strut type pointer, which contains all the information used by the process schedule. Then plug this pointer to the queue, then take a pointer in the CPU class, assign them to them. How to insert this pointer? It is to look at its weight, weight calculation method, with different algorithms (real-time processes, kernel processes, ordinary processes) according to process types (real-time processes, kernel processes, ordinary processes). Ok, so we want to find a "data structure >> About queue Operation, insert, delete, inserted into the header, placed in the team. Think about how these operations are combined with the application of the operating system. For example; the good team process is running, suddenly, due to one hardware interrupt. Generate a process It must be handled immediately. The system should insert it into the header. Ok. You can read usr./src/linux/kenrel/sched.c, don't over, don't have so many global variables, now the data structure goes over, As of the following code: Static Inline Void Move_Last_Runqueue (struct task_struct * p) {Struct task_struct * next = p-> next_run; struct task_struct * prev = p-> prev_run; / * remove from list * / next-> prev_run = prev; prev-> next_run = next; / * add back to list * / p-> next_run = & init_task; prev = init_task.prev_run; init_task.prev_run = p; p-> prev_run = prev; prev-> next_run = p;} static inline void move_first_runqueue (struct task_struct * p) {struct task_struct * next = P-> next_run; struct task_struct * prev = p-> prev_run; / * remove from list * / next-> prev_run = prev; prev-> next_run = next; / * add back to list * / p-> prev_run = & init_task Next = init_task.next_run; init_task.next_run = p; p->

转载请注明原文地址:https://www.9cbs.com/read-125805.html

New Post(0)