免费注册 查看新帖 |

Chinaunix

广告
  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2192 | 回复: 4
打印 上一主题 下一主题

printk 的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-11-03 21:59 |只看该作者 |倒序浏览
下面的文字是 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.

论坛徽章:
0
2 [报告]
发表于 2010-11-03 22:02 |只看该作者
哦,关于第 (2) 个问题应该是这样的:

printk 因为会把信息 print 到 kernel 的“环回 buffer",这样的缺点便是可能导致 log 信息的丢失.

论坛徽章:
3
金牛座
日期:2014-06-14 22:04:062015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:49:45
3 [报告]
发表于 2010-11-03 22:51 |只看该作者
回复 2# shi_wen_qiang


    是的,printk的信息有可能会丢失的

论坛徽章:
0
4 [报告]
发表于 2010-11-04 23:36 |只看该作者
谢谢大家. 但是 ‘第一个’ 问题还没人给予回答,请大家多多指点.

论坛徽章:
0
5 [报告]
发表于 2010-11-05 09:33 |只看该作者
回复 4# shi_wen_qiang


    这几句话里面没有提到自旋锁啊,提到了printk可以用于任何上下文包括中断上下文。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP