Created
October 26, 2015 09:44
-
-
Save hiboma/2dd68591aff44eb45a97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* kthread_stop - stop a thread created by kthread_create(). | |
* @k: thread created by kthread_create(). | |
* | |
* Sets kthread_should_stop() for @k to return true, wakes it, and | |
* waits for it to exit. This can also be called after kthread_create() | |
* instead of calling wake_up_process(): the thread will exit without | |
* calling threadfn(). | |
* | |
* If threadfn() may call do_exit() itself, the caller must ensure | |
* task_struct can't go away. | |
* | |
* Returns the result of threadfn(), or %-EINTR if wake_up_process() | |
* was never called. | |
*/ | |
int kthread_stop(struct task_struct *k) | |
{ | |
struct kthread *kthread; | |
int ret; | |
trace_sched_kthread_stop(k); | |
get_task_struct(k); | |
kthread = to_kthread(k); | |
barrier(); /* it might have exited */ | |
if (k->vfork_done != NULL) { | |
kthread->should_stop = 1; | |
wake_up_process(k); | |
wait_for_completion(&kthread->exited); | |
} | |
ret = k->exit_code; | |
put_task_struct(k); | |
trace_sched_kthread_stop_ret(ret); | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment