printk 的问题
下面的文字是 LDD3 里面的:
If the circular buffer fills up, printk wraps around and starts adding new data to the beginning of the buffer, overwriting the oldest data. Therefore, the logging process loses the oldest data. This problem is negligible compared with the advantages of using such a circular buffer. For example, a circular buffer allows the system to run even without a logging process, while minimizing memory waste by overwriting old data should nobody read it. Another feature of the Linux approach to messaging is that printk can be invoked from anywhere, even from an interrupt handler, with no limit on how much data can be printed. The only disadvantage is the possibility of losing some data.
(1) even from an interrupt handler
-------------------------------------------
这句话的意思就是:
interrupt handler 里面一般都会上锁(spinlock),那就是说即使在上锁(spinlock)后,printk 也是可以使用的?
(2) The only disadvantage is the possibility of losing some data
--------------------------------------------
这句话的意思不太明白,麻烦大家指点下. tks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
回复 4# shi_wen_qiang
这几句话里面没有提到自旋锁啊,提到了printk可以用于任何上下文包括中断上下文。
谢谢大家. 但是 ‘第一个’ 问题还没人给予回答,请大家多多指点.
回复 2# shi_wen_qiang
是的,printk的信息有可能会丢失的
哦,关于第 (2) 个问题应该是这样的:
printk 因为会把信息 print 到 kernel 的“环回 buffer",这样的缺点便是可能导致 log 信息的丢失.