DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] Does lthread_cond_wait need a mutex?
@ 2018-07-18  5:43 wubenqing
  2018-07-18 15:01 ` Wiles, Keith
  0 siblings, 1 reply; 8+ messages in thread
From: wubenqing @ 2018-07-18  5:43 UTC (permalink / raw)
  To: dev

Hi~
    Reference: http://doc.dpdk.org/guides-18.05/sample_app_ug/performance_thread.html?highlight=lthread
    The L-thread subsystem provides a set of functions that are logically equivalent to the corresponding functions offered by the POSIX pthread library.
    I think there is a bug with pthread_cond_wait of lthread implement.
    Look at this code, there are two lthread:

lthread1:
    pthread_mutex_lock(mutex);                 //a1
    if (predicate == FALSE) {                        //a2
        pthread_cond_wait(cond, mutex)        //a3
    }
    pthread_mutex_unlock(mutex);            //a4

int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
{
if (override) {
pthread_mutex_unlock(mutex); //a31
int rv = lthread_cond_wait(*(struct lthread_cond **)cond, 0); //a32

pthread_mutex_lock(mutex); //a33
return rv;
}
return _sys_pthread_funcs.f_pthread_cond_wait(cond, mutex);
}

lthread2:
    pthread_mutex_lock(mutex);                //b1
    predicate = TRUE;                                //b2
    pthread_mutex_unlock(mutex);            //b3
    pthread_cond_signal(cond);                //b4


    If the sequence is:
    a1->a2->a31->b1->b2->b3->b4->a32
    Will lthread1 sleep forever?

________________________________
吴本卿(研五 福州)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-08-02  7:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-18  5:43 [dpdk-dev] Does lthread_cond_wait need a mutex? wubenqing
2018-07-18 15:01 ` Wiles, Keith
2018-07-19  2:34   ` wubenqing
2018-07-19  5:21     ` Wiles, Keith
2018-07-21  1:32       ` wubenqing
2018-07-21 13:49         ` Wiles, Keith
2018-07-22 12:59           ` [dpdk-dev] 回复: " wubenqing
2018-08-02  7:03             ` [dpdk-dev] 回复: " wubenqing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).