Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1823881
  • 博文数量: 283
  • 博客积分: 10141
  • 博客等级: 上将
  • 技术积分: 2931
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-21 14:33
文章分类

全部博文(283)

文章存档

2013年(2)

2012年(2)

2011年(17)

2010年(36)

2009年(17)

2008年(18)

2007年(66)

2006年(105)

2005年(20)

分类: LINUX

2008-06-12 13:59:59

2008.06.12.
  printk可以在任何上下文中调用。如果拿不到console_sem,就写入buffer后返回。推迟输出。推迟可能导致log level的变化。见代码注释。
/*
 * This is printk.  It can be called from any context.  We want it to work.
 *
 * We try to grab the console_sem.  If we succeed, it's easy - we log the output and
 * call the console drivers.  If we fail to get the semaphore we place the output
 * into the log buffer and return.  The current holder of the console_sem will
 * notice the new output in release_console_sem() and will send it to the
 * consoles before releasing the semaphore.
 *
 * One effect of this deferred printing is that code which calls printk() and
 * then changes console_loglevel may break. This is because console_loglevel
 * is inspected when the actual printing occurs.
 */

2008.07.10.慎用printk...
    写代码的时候在收到某种数据包的时候printk了一句话,结果发现故意触发这种情况会导致性能严重下降。所以,应该使用一些宏来打印debug信息,方便在性能测试时关闭打印。可怜的处理器不应该消耗在样的工作上。


阅读(1849) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~