luolianghui 发表于 2003-7-5 19:27:06

大家讨论一下读kernel的方法

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

Dragonfly 发表于 2003-7-5 22:16:52

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.

:-D:-D:-D

_z_ 发表于 2003-7-5 22:55:39

学习ing

kakuyou 发表于 2003-7-5 23:26:40

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

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

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

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

Dragonfly 发表于 2003-7-5 23:46:54

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

:-D:-D

luolianghui 发表于 2003-7-6 22:26:26

请问kakuyou

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

Dragonfly 发表于 2003-7-6 22:37:53

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.

hibernate 发表于 2003-7-12 00:46:11

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!

Dragonfly 发表于 2003-7-12 01:10:08

http://user-mode-linux.sourceforge.net/

damage_qq 发表于 2003-8-12 20:08:13

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

Dragonfly 发表于 2003-8-12 22:59:53

damage_qq, what u said is quite right. and more like an ad for that book.:wink:

damage_qq 发表于 2003-8-15 20:49:55

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

jamesxuruo 发表于 2003-9-11 16:52:52

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

yusong 发表于 2003-9-14 22:56:19

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.

beijisnow 发表于 2003-10-23 00:39:04

:roll::roll::roll:
页: [1] 2 3 4 5
查看完整版本: 大家讨论一下读kernel的方法