DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Wiles, Keith" <keith.wiles@intel.com>
To: "wubenqing@ruijie.com.cn" <wubenqing@ruijie.com.cn>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] Does lthread_cond_wait need a mutex?
Date: Wed, 18 Jul 2018 15:01:02 +0000	[thread overview]
Message-ID: <84056D8E-0669-403A-ABE4-005CE1FC57FB@intel.com> (raw)
In-Reply-To: <82A10A71B70FF2449A8AD233969A45A11DB0310F@FZEX4.ruijie.com.cn>



> On Jul 17, 2018, at 10:43 PM, wubenqing@ruijie.com.cn wrote:
> 
> 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?

Maybe is it possible, my brain is not working this morning. Please remember that lthreads must give up control or lthread will continue to and can not be preempted.

Does that fix the problem?

> 
> ________________________________
> 吴本卿(研五 福州)

Regards,
Keith


  reply	other threads:[~2018-07-18 15:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-18  5:43 wubenqing
2018-07-18 15:01 ` Wiles, Keith [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84056D8E-0669-403A-ABE4-005CE1FC57FB@intel.com \
    --to=keith.wiles@intel.com \
    --cc=dev@dpdk.org \
    --cc=wubenqing@ruijie.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).