From patchwork Wed May 11 16:41:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 67561 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp294665qge; Wed, 11 May 2016 08:48:03 -0700 (PDT) X-Received: by 10.140.194.138 with SMTP id p132mr4452928qha.78.1462981683141; Wed, 11 May 2016 08:48:03 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id b70si5621069qge.25.2016.05.11.08.48.02; Wed, 11 May 2016 08:48:03 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B7B8D61702; Wed, 11 May 2016 15:48:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 9B9676166D; Wed, 11 May 2016 15:44:21 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 43CB861650; Wed, 11 May 2016 15:44:15 +0000 (UTC) Received: from mail-lf0-f41.google.com (mail-lf0-f41.google.com [209.85.215.41]) by lists.linaro.org (Postfix) with ESMTPS id 5C0D56163C for ; Wed, 11 May 2016 15:44:11 +0000 (UTC) Received: by mail-lf0-f41.google.com with SMTP id j8so53739457lfd.2 for ; Wed, 11 May 2016 08:44:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ucnsCoZCQBbKMyBikiNu8LRBSYRRQILEKnUCfWxbGbI=; b=M05km4qCMdQUokBi6uzNzrYJbC62XaDJkPZ6KWfK/PCzloxwN47PgaGCV7r/2pYHHR 5SFFgmiEehE5QyonfqLIIUQ4K7GtI/ZV9xDcGi+i3aotGq1p0/4QeZsc0sw6NBKNfp6N yaQrMutYHYoUcOk1ezmogYufKHkxR1Uk3Q4LBhoDGHKx/g12uKdSVFpPBcAPH0bqPysH Q73loJgyuZvUevmGLrSAgD+4m2zgIhGiBTFx/4oHP4i7GnACuCf6GzurhnYvb7SpfnNZ OareQKYoWeHqkMgdzhw/xe467JbiLrSTyJItjc90idncXsy2Z2k5GyTSq9SDO3/xL+AT o23A== X-Gm-Message-State: AOPr4FWqkf6wlEZX/KognhqifDi8F+U4S9QarWlZ7NDvPuLTTEL45PS4sniiyVgIGKD2fePhXcE= X-Received: by 10.112.125.9 with SMTP id mm9mr1896345lbb.45.1462981450323; Wed, 11 May 2016 08:44:10 -0700 (PDT) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-90-46.cust.bredband2.com. [83.233.90.46]) by smtp.gmail.com with ESMTPSA id n37sm1421164lfg.46.2016.05.11.08.44.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 May 2016 08:44:09 -0700 (PDT) From: Christophe Milard To: brian.brooks@linaro.org, mike.holmes@linaro.org, lng-odp@lists.linaro.org Date: Wed, 11 May 2016 18:41:48 +0200 Message-Id: <1462984942-53326-5-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1462984942-53326-1-git-send-email-christophe.milard@linaro.org> References: <1462984942-53326-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv6 04/38] helpers: linux: creating common entry for process and thread X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" odph_linux_pthread_t and odph_linux_process_t are joined, creating odph_odpthread_t. Tests should be using the latter only so that the actual implementation of the ODP thread don't leak in the test itself. (odph_odpthread_t is opaque to the test, and is common to both thread and process omplementation of ODP threads) odph_linux_pthread_t and odph_linux_process_t are kept for compatibility, but should be removed in the future. Signed-off-by: Christophe Milard --- helper/include/odp/helper/linux.h | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/helper/include/odp/helper/linux.h b/helper/include/odp/helper/linux.h index c6736a0..f99b88a 100644 --- a/helper/include/odp/helper/linux.h +++ b/helper/include/odp/helper/linux.h @@ -44,7 +44,6 @@ typedef struct { odph_linux_thr_params_t thr_params; } odph_linux_pthread_t; - /** Linux process state information */ typedef struct { pid_t pid; /**< Process ID */ @@ -52,6 +51,44 @@ typedef struct { int status; /**< Process state change status */ } odph_linux_process_t; +/** odpthread linux type: whether an ODP thread is a linux thread or process */ +typedef enum odph_odpthread_linuxtype_e { + ODPTHREAD_NOT_STARTED = 0, + ODPTHREAD_PROCESS, + ODPTHREAD_PTHREAD +} odph_odpthread_linuxtype_t; + +/** odpthread parameters for odp threads (pthreads and processes) */ +typedef struct { + int (*start)(void *); /**< Thread entry point function */ + void *arg; /**< Argument for the function */ + odp_thread_type_t thr_type; /**< ODP thread type */ + odp_instance_t instance; /**< ODP instance handle */ +} odph_odpthread_params_t; + +/** The odpthread starting arguments, used both in process or thread mode */ +typedef struct { + odph_odpthread_linuxtype_t linuxtype; + odph_odpthread_params_t thr_params; /*copy of thread start parameter*/ +} odph_odpthread_start_args_t; + +/** Linux odpthread state information, used both in process or thread mode */ +typedef struct { + odph_odpthread_start_args_t start_args; + int cpu; /**< CPU ID */ + int last; /**< true if last table entry */ + union { + struct { /* for thread implementation */ + pthread_t thread_id; /**< Pthread ID */ + pthread_attr_t attr; /**< Pthread attributes */ + } thread; + struct { /* for process implementation */ + pid_t pid; /**< Process ID */ + int status; /**< Process state chge status*/ + } proc; + }; +} odph_odpthread_t; + /** * Creates and launches pthreads *