[dpdk-dev] [PATCH 1/2] eal: add API that sleeps while waiting for threads

Stephen Hemminger stephen at networkplumber.org
Thu Oct 11 22:32:13 CEST 2018


On Thu, 11 Oct 2018 20:57:52 +0100
Ferruh Yigit <ferruh.yigit at intel.com> wrote:

> +/*
> + * Wait until a lcore finished its job by sleeping.
> + * Sleep time will be times of 'usec'
> + */
> +int
> +rte_eal_wait_lcore_sleep(unsigned slave_id, size_t usec)
> +{
> +	if (lcore_config[slave_id].state == WAIT)
> +		return 0;
> +
> +	while (lcore_config[slave_id].state != WAIT &&
> +	       lcore_config[slave_id].state != FINISHED)
> +			usleep(usec);
> +
> +	rte_rmb();
> +
> +	/* we are in finished state, go to wait state */
> +	lcore_config[slave_id].state = WAIT;
> +	return lcore_config[slave_id].ret;
> +}
> +

Since lcore threads are really pthreads you could avoid doing polling by
using a pthread condition (ie. pthread_cond_wait and/or pthread_cond_timedwait)


More information about the dev mailing list