One of the most basic kernel messaging systems is the printk() function. The kernel uses printk() as opposed to printf() because the standard C library is not linked to the kernel. printk() uses the same interface as printf() does and displays up to 1,024 characters to the console. The printk() function operates by trying to grab the console semaphore, place the output into the console's log buffer, and then call the console driver to flush the buffer. If printk() cannot grab the console semaphore, it places the output into the log buffer and relies on the process that has the console semaphore to flush the buffer. The log-buffer lock is taken before printk() places any data into the log buffer, so concurrent calls to printk() do not trample each other. If the console semaphore is being held, numerous calls to printk() can occur before the log buffer is flushed. So, do not rely on printk() statements to indicate any program timing.
printk() 将输出打倒了内核提供的 console buffer 里面,再由这个 console 的驱动将其打印出来。
LG_OPEN 于 2012-09-19 12:31:42发表:
那个游客说的对,虚拟终端是不能显示的
于 2012-09-18 20:54:24发表:
在字符界面的终端里可以,图形界面是一个终端模拟器
deepwhite 于 2010-09-02 11:46:11发表:
[i=s] 本帖最后由 deepwhite 于 2010-9-2 12:04 编辑 [/i]
printk () 打出来的东西不是打倒 stdout 或者 stderr 上,所以你没法直接看到。
你可以通过 dmesg 来查看。
附 printk() 作用的解释, 取自 linux kernel primer:
2.7.1. printk()
One of the most basic kernel messaging systems is the printk() function. The kernel uses printk() as opposed to printf() because the standard C library is not linked to the kernel. printk() uses the same interface as printf() does and displays up to 1,024 characters to the console. The printk() function operates by trying to grab the console semaphore, place the output into the console's log buffer, and then call the console driver to flush the buffer. If printk() cannot grab the console semaphore, it places the output into the log buffer and relies on the process that has the console semaphore to flush the buffer. The log-buffer lock is taken before printk() places any data into the log buffer, so concurrent calls to printk() do not trample each other. If the console semaphore is being held, numerous calls to printk() can occur before the log buffer is flushed. So, do not rely on printk() statements to indicate any program timing.
printk() 将输出打倒了内核提供的 console buffer 里面,再由这个 console 的驱动将其打印出来。
denvor 于 2010-09-02 11:25:29发表:
再一天,谁来帮帮我啊?
denvor 于 2010-09-01 23:23:45发表:
又是一天,还是没人关心一下啊
denvor 于 2010-09-01 10:51:04发表:
都一整天了,谁来看看啊
denvor 于 2010-08-31 23:33:43发表:
不是吧,都快一整天了,还没人来说?
denvor 于 2010-08-31 11:37:28发表:
不是吧。。。没人知道?