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

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

rickie 发表于 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() 的定义.

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

fishcrazy 发表于 2003-4-2 13:20:56

看来我真的很必要重新开始一次了。

努力!努力!继续努力!

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

English & Linux

rickie 发表于 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?

Dragonfly 发表于 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.
页: 1 [2]
查看完整版本: 内核阅读日记[1.18]