打印

大家讨论一下读kernel的方法

大家讨论一下读kernel的方法

我现在正在读内核,发现没有一本书把所有代码都讲解出来,都只是摘录了一些代码,我尝试一行一行的把所有代码都读懂,但这样十分费劲,而且效率很低,想请问读过内核的各位介绍些好方法,多谢!

TOP

my way is to grasp the call graph and data structures at first. and if u can know the purpose of one function, u need not know every detail about it. once u go through whole flow once, then u can go deeper.
and for some code has algorithm, u had better know that algorithm first. instead of reading code to know the algoritm.
for code implement protocol. for example a scsi protocol. u had better have a scsi command reference at hand.
most of the time, i skip the asm code and machine dependent code, since i do not go that deeper. i read code because i need do my research. if u have no such requirement, try to find one.

    
Time is always not enough!

TOP

学习ing

TOP

一行一行的读?不会有任何效果,像代码这么枯燥的东西肯定是看后面忘前面,我提出的方法如下:

1。首先确定一个自己感兴趣的部分,例如内存管理(实际上不是好的例子,因为这是最难debug的部分)。
2。大致读一下,确定自己糊涂的地方,添加额外的debug信息或者...改成自己认为正确的东西。
3。编译,换内核,验证自己的想法。

这期间你会各种问题,例如编译的问题,各种文件的写法,编译器的使用,甚至系统崩溃,那时你又需要debug crash文件,总之你如果花上几个月(个人水平不同)能完成上面的步骤,那你绝对可以傲视绝大部分天天捧着source读的人了,呵呵。

以我的经验,真正的程序员不是会写程序的人,而是会debug和测试自己程序的人

TOP

hehe, kakuyou 's thought is better than me.
use user mode linux can let u use gdb to monitor kernel.

  
Time is always not enough!

TOP

请问kakuyou

是直接在linux,root下编译,调试内核吗,万一修改错了,系统崩溃了,那就惨了,不过学内核也不应该怕这些,呵呵,

TOP

u should not touch u current kernel source code and kernel image. u need use another copy of kernel source and modify in that.
and if possible. use user mode linux is a good choice.
Time is always not enough!

TOP

may be I can ask Dragonfly something about 'user mode linux'
I don't know what it is,since I never heard it.
Can you introduce it to me?
Is it something you can compile the kernel in time and use it to check that immediately?
If so,I would install one.
The next term I have a course called practice to operation system,
and it will do me a great help!
Motion won't grow up by itself, but may be stimulated by others. And so ,communication and interaction are needed,and the more ,the better!

TOP

http://user-mode-linux.sourceforge.net/
Time is always not enough!

TOP

我想,对于想要深入学习LINUX的人来说,源代码阅读和理解是一项重要的基本功,推荐浙江大学出版社出的<<LINUX 源代码情景分析>>,而且我认为阅读源代码不应该一下子就深入细节,应该先有一个总体的把握,而且是一个反复的,螺旋式的过程,读到后面在返回前面,再读到后面又返回前面,<<LINUX 源代码情景分析>>在这方面给我们提供了很好的学习平台,大家不妨买来看一看,一定会大有帮助的.

TOP

damage_qq, what u said is quite right. and more like an ad for that book.  
Time is always not enough!

TOP

谢谢,这本书是两位原浙江大学的教授毛德操(现定居美国)和胡希明合作出版的,本书从具体,鲜活的源代码入手作情景分析,再分析过程中逐步引入相关数据结构和相互的联系,介绍1具体函数的逻辑流程及代码的高超技巧,让读者掌握LINUX的编程技巧。

TOP

i am very interested in usr-mode-linux,i have done some experiment according to the web site(use-mode),but all are fail,nothing happened.
so,Dragronfly,would you please talk something about it?
thanks very much

TOP

I have some exp on Windows user mode debug. It is not easy because there is no code to check, only depend on the asm. Debugging the kernel also is suck. Need to two computers.

However, I am a new fresh on Linux. I even don't know how to debug user mode in Linux. This forum is the beginning for me. I wish to learn some and quickly master Linux.

TOP

    

TOP