linux pthread_suspend

后端 未结 5 2004
醉酒成梦
醉酒成梦 2021-02-08 03:36

Looks like linux doesnt implement pthread_suspend and continue, but I really need em.

I have tried cond_wait, but it is too slow. The work being threaded mostly execut

5条回答
  •  借酒劲吻你
    2021-02-08 04:01

    It seems to me that such a solution (that is, using "pthread_suspend" and "pthread_continue") is inevitably racy.

    An arbitrary amount of time can elapse between the worker thread finishing work and deciding to suspend itself, and the suspend actually happening. If the main thread decides during that time that that worker thread should be working again, the "continue" will have no effect and the worker thread will suspend itself regardless.

    (Note that this doesn't apply to methods of suspending that allow the "continue" to be queued, like the sigwait() and read() methods mentioned in other answers).

提交回复
热议问题