From patchwork Thu Feb 5 09:57:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 44416 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f198.google.com (mail-we0-f198.google.com [74.125.82.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0CEE621521 for ; Thu, 5 Feb 2015 09:58:30 +0000 (UTC) Received: by mail-we0-f198.google.com with SMTP id p10sf808906wes.1 for ; Thu, 05 Feb 2015 01:58:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=fFmeYrrxemTgml4wu5tQnWFIk/h+lL6xD+oSdMdozgc=; b=J9CxvHPnx8ZWOnKoDra+ODJ9DSyO3sI0MRbUfHdKTFVzpx7advyl4zWTkArQKdDVOD z+++ioSKEvcc/n6ZYBvlnPRt1aPL3/EmYPXpEE+pH1ALbG9kx+Mx01vEjTsW0Bcglklj By2diFyG3hVQauR4KZxyr++7VXk7xhcigC9tDD4t9fJ1KLRC15u6qMnTx/ke4NpFg3Wn VgsT5f1upVNEFLeXm/4AGJFr39tHP36z04kdIMCZVygcZVRKhtCIT4XmmlRFXbJugxBb ZNWw7lu9mzJhgw/t3XjxG8Itw7ltN/3XTvdfeKvKFa8/tHN/N4m9DDeVWyvS7RM2P/zN 96rQ== X-Gm-Message-State: ALoCoQlGHjMoRELexJzjhQOQ3dNPnspKzenJHeR6gkqPmeXc4OAj+S3ot3MqZOoAkwV5l2PmKcZ2 X-Received: by 10.180.109.13 with SMTP id ho13mr1103828wib.7.1423130309287; Thu, 05 Feb 2015 01:58:29 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.74 with SMTP id r10ls120483lag.17.gmail; Thu, 05 Feb 2015 01:58:29 -0800 (PST) X-Received: by 10.152.207.108 with SMTP id lv12mr2495723lac.94.1423130309031; Thu, 05 Feb 2015 01:58:29 -0800 (PST) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id z10si3567528lbr.11.2015.02.05.01.58.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Feb 2015 01:58:28 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id l4so6064918lbv.13 for ; Thu, 05 Feb 2015 01:58:28 -0800 (PST) X-Received: by 10.112.164.101 with SMTP id yp5mr2435319lbb.82.1423130308913; Thu, 05 Feb 2015 01:58:28 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1034811lbj; Thu, 5 Feb 2015 01:58:28 -0800 (PST) X-Received: by 10.229.70.133 with SMTP id d5mr6644266qcj.2.1423130307583; Thu, 05 Feb 2015 01:58:27 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id g3si5537184qas.62.2015.02.05.01.57.56 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 05 Feb 2015 01:58:27 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YJJC7-0008QS-7Z; Thu, 05 Feb 2015 09:57:55 +0000 Received: from mail-qg0-f50.google.com ([209.85.192.50]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YJJBw-0008OX-RY for lng-odp@lists.linaro.org; Thu, 05 Feb 2015 09:57:44 +0000 Received: by mail-qg0-f50.google.com with SMTP id j5so5385935qga.9 for ; Thu, 05 Feb 2015 01:57:39 -0800 (PST) X-Received: by 10.224.65.137 with SMTP id j9mr6141311qai.47.1423130259644; Thu, 05 Feb 2015 01:57:39 -0800 (PST) Received: from mcpro03.emea.nsn-net.net (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id r8sm2494306qad.43.2015.02.05.01.57.37 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Feb 2015 01:57:38 -0800 (PST) From: Petri Savolainen To: lng-odp@lists.linaro.org Date: Thu, 5 Feb 2015 11:57:14 +0200 Message-Id: <1423130234-6305-4-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1423130234-6305-1-git-send-email-petri.savolainen@linaro.org> References: <1423130234-6305-1-git-send-email-petri.savolainen@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v3 4/4] api: thread: Added odp_thread_count X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: petri.savolainen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Improved thread id documentation and added odp_thread_count(), which returns number of active threads. Signed-off-by: Petri Savolainen --- include/odp/api/thread.h | 17 +++++++++++++++++ platform/linux-generic/odp_thread.c | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/include/odp/api/thread.h b/include/odp/api/thread.h index 844f45a..6b3b39b 100644 --- a/include/odp/api/thread.h +++ b/include/odp/api/thread.h @@ -25,11 +25,28 @@ extern "C" { /** * Get thread identifier * + * Returns the thread identifier of the current thread. Thread ids range from 0 + * to ODP_CONFIG_MAX_THREADS-1. The ODP thread id is assinged by + * odp_init_local() and freed by odp_term_local(). Thread id is unique within + * the ODP instance. + * * @return Thread identifier of the current thread */ int odp_thread_id(void); /** + * Thread count + * + * Returns the current ODP thread count. This is the number of active threads + * running the ODP instance. Each odp_init_local() call increments and each + * odp_term_local() call decrements the count. The count is always between 1 and + * ODP_CONFIG_MAX_THREADS. + * + * @return Current thread count + */ +int odp_thread_count(void); + +/** * @} */ diff --git a/platform/linux-generic/odp_thread.c b/platform/linux-generic/odp_thread.c index ac8c9de..f6c900b 100644 --- a/platform/linux-generic/odp_thread.c +++ b/platform/linux-generic/odp_thread.c @@ -118,6 +118,10 @@ int odp_thread_id(void) return this_thread->thr_id; } +int odp_thread_count(void) +{ + return odp_atomic_load_u32(&thread_globals->num); +} int odp_cpu_id(void) {