From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH 1/2] eal: add API that sleeps while waiting for threads Date: Thu, 11 Oct 2018 13:32:13 -0700 Message-ID: <20181011133213.2c37a464@xeon-e3> References: <20181011195753.4778-1-ferruh.yigit@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: Ferruh Yigit Return-path: Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id EB29E1B178 for ; Thu, 11 Oct 2018 22:32:21 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id w14-v6so4763106plp.6 for ; Thu, 11 Oct 2018 13:32:21 -0700 (PDT) In-Reply-To: <20181011195753.4778-1-ferruh.yigit@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, 11 Oct 2018 20:57:52 +0100 Ferruh Yigit 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)