DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: "Yigit, Ferruh" <ferruh.yigit@intel.com>,
	"Richardson, Bruce" <bruce.richardson@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"Yigit, Ferruh" <ferruh.yigit@intel.com>,
	"stephen@networkplumber.org" <stephen@networkplumber.org>
Subject: Re: [dpdk-dev] [PATCH v2 1/2] eal: add API that sleeps while waiting	for threads
Date: Tue, 16 Oct 2018 09:05:16 +0000	[thread overview]
Message-ID: <2601191342CEEE43887BDE71AB9772580102FE76D1@IRSMSX106.ger.corp.intel.com> (raw)
In-Reply-To: <20181015222110.61564-1-ferruh.yigit@intel.com>

> 
> +/*
> + * Wait until a lcore finished its job by pthread condition.
> + */
> +int
> +rte_eal_wait_lcore_sleep(unsigned slave_id)
> +{
> +	if (lcore_config[slave_id].state == WAIT)
> +		return 0;
> +
> +	pthread_mutex_lock(&rte_eal_thread_mutex[slave_id]);
> +	while (lcore_config[slave_id].state != WAIT &&
> +	       lcore_config[slave_id].state != FINISHED)
> +		pthread_cond_wait(&rte_eal_thread_cond[slave_id],
> +				&rte_eal_thread_mutex[slave_id]);
> +	pthread_mutex_unlock(&rte_eal_thread_mutex[slave_id]);
> +
> +	/* we are in finished state, go to wait state */
> +	lcore_config[slave_id].state = WAIT;
> +	return lcore_config[slave_id].ret;
> +}
> +

Actually, another question - could that 2 or more threads wait for the same core simultaneously?
If yes, then 2-nd thread in that function might stuck forever.
In that case it is better to use cond_timed_wait() here and cond_broadcast() above.
Konstantin

      parent reply	other threads:[~2018-10-16  9:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-11 19:57 [dpdk-dev] [PATCH " Ferruh Yigit
2018-10-11 19:57 ` [dpdk-dev] [PATCH 2/2] examples: sleep while waiting worker threads to terminate Ferruh Yigit
2018-10-11 20:32 ` [dpdk-dev] [PATCH 1/2] eal: add API that sleeps while waiting for threads Stephen Hemminger
2018-10-15 22:21 ` [dpdk-dev] [PATCH v2 " Ferruh Yigit
2018-10-15 22:21   ` [dpdk-dev] [PATCH v2 2/2] examples: sleep while waiting worker threads to terminate Ferruh Yigit
2023-06-12  2:38     ` Stephen Hemminger
2018-10-16  8:42   ` [dpdk-dev] [PATCH v2 1/2] eal: add API that sleeps while waiting for threads Ananyev, Konstantin
2018-10-16  9:05   ` Ananyev, Konstantin [this message]

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=2601191342CEEE43887BDE71AB9772580102FE76D1@IRSMSX106.ger.corp.intel.com \
    --to=konstantin.ananyev@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=stephen@networkplumber.org \
    /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).