How to wait for a linux kernel thread (kthread)to exit?

后端 未结 4 1941
再見小時候
再見小時候 2021-01-03 07:36

I have just started programing on Linux kernel threads. I have a problem which I would like to share with you guys. My code is:



        
4条回答
  •  南方客
    南方客 (楼主)
    2021-01-03 08:00

    /* Wait for kthread_stop */
    set_current_state(TASK_INTERRUPTIBLE);
    while (!kthread_should_stop()) {
        schedule();
        set_current_state(TASK_INTERRUPTIBLE);
    }
    

    Check this article for more information: "Sleeping in the Kernel".

提交回复
热议问题