gpt4 book ai didi

linux 内核 printk 输出

转载 作者:太空宇宙 更新时间:2023-11-04 11:23:02 27 4
gpt4 key购买 nike

我是 Linux 内核开发的新手,当我尝试通过在 timekeep.c 文件中添加一个 printk 函数来修改系统调用函数时,比如

 printk("BEGIN!$$$$$\n");

dmesg 实用程序给我的输出如下:

[   75.919335] BEGIN!$$$$$
[ 75.919337] BEGIN!$$$$$
[ 75.919340] BEGIN!$$$$$
[ 75.919343] BEGIN!$$$$$
[ 75.919347] BEGIN!$$$$$
[ 75.919349] BEGIN!$$$$$
[ 75.919353] BEGIN!$$$$$
[ 75.919355] BEGIN!$$$$$
[ 75.919358] BEGIN!$$$$$
[ 75.919361] BEGIN!$$$$$
[ 75.919364] BEGIN!$$$$$
[ 75.919367] BEGIN!$$$$$
[ 75.919370] BEGIN!$$$$$
[ 75.919374] BEGIN!$$$$$

我真的不明白[]里的那些是怎么产生的。有人可以给我一些提示吗?

最佳答案

您的内核启用了 CONFIG_PRINTK_TIME 选项。此选项负责 printk() 消息之前的时间戳字段。来自内核配置选项

 "Selecting this option causes time stamps of the `printk()` messages to be
added to the output of the `syslog()` system call and at the console."

来源:https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/lib/Kconfig.debug#n2

此选项可在内核配置时通过“Kernel Hacking”配置字段进行配置。您可以从内核命令行参数启用/禁用它:printk.time=0(禁用)或 printk.time=1(启用)。

关于linux 内核 printk 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16765658/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com