linux内核waitqueues - printk没有显示在消息日志中

时间:2012-05-21 14:52:21

标签: linux-kernel

我注意到内核模块中有一些奇怪的行为。当我运行以下代码(使用waitqueues)时。在finish_wait()之后,printk()不会出现在内核日志中。 第5行也只打印一次。有什么想法发生了什么?

DEFINE_WAIT(wait);
DECLARE_WAIT_QUEUE_HEAD(wait_q);
flags |= O_NONBLOCK;
while (( err = kthread->sock->ops->accept(kthread->sock, kthread->sock_send, flags) ) < 0){
    printk("%s: before prepare_to_wait err = -%d\n", __func__,err);
    prepare_to_wait(&wait_q, &wait, TASK_INTERRUPTIBLE);
    if(kthread_should_stop()){
        printk("%s: killing thread\n", __func__);
        msleep(1000);   
        finish_wait(&wait_q, &wait);
        goto close_and_out;
    }
    schedule();
}
finish_wait(&wait_q, &wait);
printk("after finish wait: This doesn't show up in kernel logs...\n");

1 个答案:

答案 0 :(得分:2)

将优先级添加到日志消息中:

喜欢:printk(KERN_ALERT你的消息); KERN_ALERT和您的消息之间也没有“逗号” 如果不是KERN_ALERT,请尝试使用不同的级别。

RGDS, 软质皮

相关问题