QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 42608|回复: 71

大家讨论一下读kernel的方法

[复制链接]
发表于 2003-7-5 19:27:06 | 显示全部楼层 |阅读模式
我现在正在读内核,发现没有一本书把所有代码都讲解出来,都只是摘录了一些代码,我尝试一行一行的把所有代码都读懂,但这样十分费劲,而且效率很低,想请问读过内核的各位介绍些好方法,多谢!
发表于 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.

    
回复

使用道具 举报

发表于 2003-7-5 22:55:39 | 显示全部楼层
学习ing
回复

使用道具 举报

发表于 2003-7-5 23:26:40 | 显示全部楼层
一行一行的读?不会有任何效果,像代码这么枯燥的东西肯定是看后面忘前面,我提出的方法如下:

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

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

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

使用道具 举报

发表于 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.

  
回复

使用道具 举报

 楼主| 发表于 2003-7-6 22:26:26 | 显示全部楼层

请问kakuyou

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

使用道具 举报

发表于 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.
回复

使用道具 举报

发表于 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!
回复

使用道具 举报

发表于 2003-7-12 01:10:08 | 显示全部楼层
http://user-mode-linux.sourceforge.net/
回复

使用道具 举报

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

使用道具 举报

发表于 2003-8-12 22:59:53 | 显示全部楼层
damage_qq, what u said is quite right. and more like an ad for that book.  
回复

使用道具 举报

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

使用道具 举报

发表于 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
回复

使用道具 举报

发表于 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.
回复

使用道具 举报

发表于 2003-10-23 00:39:04 | 显示全部楼层
    
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-3-28 18:13 , Processed in 0.055088 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表