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