906
906

Reputation: 55

How to know pthread is stopped?

I am new in programming world. I need to move some part of code from kernel space to userland. However, I cannot find the replacement of kthread_should_stop() in pThread. May I know how should I use below code in userland?

 while(!kthread_should_stop()){
 ...
 }

Thanks

Upvotes: 1

Views: 152

Answers (1)

CL.
CL.

Reputation: 180020

There is nothing magic about kthread_should_stop(); the kthread_stop() function just sets a boolean variable and wakes up the thread.

Depending on what mechanism you are already using to communicate between threads, you can use a Pthreads condition variable or an eventfd or something like that to implement the stop signal.

Upvotes: 1

Related Questions