QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

楼主: fishcrazy

内核阅读日记[1.18]

[复制链接]
发表于 2003-3-30 10:32:38 | 显示全部楼层
of course, they are quite different in many places. from data structures to algorithms , to code... so if u really want to know linux, pls read linux kernel. if u want to learn os better, u can read any one, minix, linux, mach..
回复

使用道具 举报

 楼主| 发表于 2003-4-1 16:46:57 | 显示全部楼层
To cheungming:
      
         Thanks for your suggestion!

         But I' m sorry to read so poor English...

        It's a joke.   Thank you!
回复

使用道具 举报

发表于 2003-4-1 18:50:54 | 显示全部楼层
fishcrazy, 据我所知, linux 内核中是用printk() 而非 printf(). 当一个事件发生时, 例如内核发现数据结构错误, 它就会使用printk() 向系统终端打印消息. 而内核一般在下列几种情况调用printk():
1. 紧急事件: 例如, 函数panic() 调用. 当内核探测到不可恢复内部错误时, 内核就会调用panic(), 同时尽量安全关机. 在panic()内就会调用 printk() 提醒用户系统将关机.
2. 调试: 用printk() 打印调试信息.
3. 一般信息. 当机器初启时, 系统用printk() 打印一些信息.

你可以在 kernel/printk.c 找到printk() 的定义.
回复

使用道具 举报

发表于 2003-4-2 00:00:39 | 显示全部楼层
hehe, my english is really poor, i know. and all my friends say this. but i have to use english because that this is the only language i can use here.

printk is very similar to printf. and printk has 7 different levels. but the main purpose of prink is to print to log, not to console. only the higher level printk will print out to console. this can be adjust by dmesg -nx
回复

使用道具 举报

 楼主| 发表于 2003-4-2 13:20:56 | 显示全部楼层
看来我真的很必要重新开始一次了。

努力!努力!继续努力!

English is important to Developers, so I want to impove such capability too.

English & Linux
回复

使用道具 举报

发表于 2003-4-2 15:00:10 | 显示全部楼层
yeah.  printk() is the kernel's internal message-loging function. From my point of view, we can actually use it to print some information, e.g. debugging messages,   to the systme console. I assume printk is used in kernel mode, and printf is used in user mode.  correct?
回复

使用道具 举报

发表于 2003-4-2 22:38:55 | 显示全部楼层
yes, exactly. except that printk does not send contents to the system console, but to the log buffer. and klogd or syslogd will send the contents to the system console only when its level is higher than a certain level.  see printk.c for more detail.
btw, the printk can sleep. so do not use it in interrupt context unless u know what u are doing.
回复

使用道具 举报

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

本版积分规则

GMT+8, 2024-5-20 10:19 , Processed in 0.080048 second(s), 13 queries .

© 2021 Powered by Discuz! X3.5.

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