From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 798433256 for ; Tue, 16 Oct 2018 11:05:19 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2018 02:05:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,388,1534834800"; d="scan'208";a="266073346" Received: from irsmsx108.ger.corp.intel.com ([163.33.3.3]) by orsmga005.jf.intel.com with ESMTP; 16 Oct 2018 02:05:17 -0700 Received: from irsmsx106.ger.corp.intel.com ([169.254.8.45]) by IRSMSX108.ger.corp.intel.com ([169.254.11.187]) with mapi id 14.03.0319.002; Tue, 16 Oct 2018 10:05:16 +0100 From: "Ananyev, Konstantin" To: "Yigit, Ferruh" , "Richardson, Bruce" CC: "dev@dpdk.org" , "Yigit, Ferruh" , "stephen@networkplumber.org" Thread-Topic: [dpdk-dev] [PATCH v2 1/2] eal: add API that sleeps while waiting for threads Thread-Index: AQHUZM0Sa+lwrSFHMkmwo2BXkK/MZKUhlA0w Date: Tue, 16 Oct 2018 09:05:16 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772580102FE76D1@IRSMSX106.ger.corp.intel.com> References: <20181011195753.4778-1-ferruh.yigit@intel.com> <20181015222110.61564-1-ferruh.yigit@intel.com> In-Reply-To: <20181015222110.61564-1-ferruh.yigit@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOTRhNGMwZmUtYjU0MS00ZjQ2LWFmY2MtYjQ0OWU4MTZjZmJlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZ2cwUW1oeE0rOHFWN3NSb3JCYzRWSVUyRFprNHpjcmRcL2c2NGswRHdncjlcL3lDZkVxdjg0WHVLajd2Y05xaU5QIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 1/2] eal: add API that sleeps while waiting for threads X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Oct 2018 09:05:20 -0000 >=20 > +/* > + * 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 =3D=3D WAIT) > + return 0; > + > + pthread_mutex_lock(&rte_eal_thread_mutex[slave_id]); > + while (lcore_config[slave_id].state !=3D WAIT && > + lcore_config[slave_id].state !=3D 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 =3D 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