linux 内核 printk 输出

标签 linux kernel output printk

我是 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/

相关文章:

java - 邮件被防火墙阻止

linux-kernel - 为什么我的 printk 消息最近在日志文件中更新了?

c++ - 编译器或标准 C++ 库 - 新建和删除

带有混合通配符的输出文件

node.js - 响应日期与 MongoDB 不同

python - affdex.cpp :9:31: fatal error: pybind11/pybind11. h : No such file or directory #include <pybind11/pybind11. h>

linux - 我需要在多线程读取调用中保护 fd 吗?

c - 如何在 C 中以已知格式逐行读取文件

java - 没有显示输出,找不到错误(Java)

php - HostGator 上的 Linux 服务器说找不到类 'HTTPRequest'