pthread_yield和pthread_may_yield之间的区别?

时间:2016-01-28 06:52:24

标签: multithreading

pthread_yield p_thread_may 产量之间有什么区别。

1 个答案:

答案 0 :(得分:1)

pthread_yield()使调用线程立即放弃CPU。

然而,如果当前线程已经用完了给定的量子,pthread_may_yield()将会产生。

pthread_may_yield ()
{

    /* Whether this thread has used up its allocated time slice?
       Set Variable to True if yes. */

    if (thread has used up given quantum) {
        pthread_yield();
    }
}