3

我注意到内核模块中有一些奇怪的行为。当我运行以下代码(使用等待队列)时。在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");
4

1 回答 1

2

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

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

Rgds,软软的

于 2012-05-21T17:31:26.760 回答