diff mbox

[09/11] linux-generic: thread: implemented thrmask_worker and control

Message ID 1436449585-23252-10-git-send-email-maxim.uvarov@linaro.org
State Accepted
Commit 0ebee2bb8078c5a42f4047e3c3d09e03a65141fb
Headers show

Commit Message

Maxim Uvarov July 9, 2015, 1:46 p.m. UTC
From: Petri Savolainen <petri.savolainen@nokia.com>

Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com>
Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 platform/linux-generic/odp_thread.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/odp_thread.c b/platform/linux-generic/odp_thread.c
index 42afc5f..9905c78 100644
--- a/platform/linux-generic/odp_thread.c
+++ b/platform/linux-generic/odp_thread.c
@@ -36,6 +36,8 @@  typedef struct {
 	odp_thrmask_t  worker;
 	odp_thrmask_t  control;
 	uint32_t       num;
+	uint32_t       num_worker;
+	uint32_t       num_control;
 	odp_spinlock_t lock;
 } thread_globals_t;
 
@@ -93,10 +95,13 @@  static int alloc_id(odp_thread_type_t type)
 		if (odp_thrmask_isset(all, thr) == 0) {
 			odp_thrmask_set(all, thr);
 
-			if (type == ODP_THREAD_WORKER)
+			if (type == ODP_THREAD_WORKER) {
 				odp_thrmask_set(&thread_globals->worker, thr);
-			else
+				thread_globals->num_worker++;
+			} else {
 				odp_thrmask_set(&thread_globals->control, thr);
+				thread_globals->num_control++;
+			}
 
 			thread_globals->num++;
 			return thr;
@@ -118,10 +123,13 @@  static int free_id(int thr)
 
 	odp_thrmask_clr(all, thr);
 
-	if (thread_globals->thr[thr].type == ODP_THREAD_WORKER)
+	if (thread_globals->thr[thr].type == ODP_THREAD_WORKER) {
 		odp_thrmask_clr(&thread_globals->worker, thr);
-	else
+		thread_globals->num_worker--;
+	} else {
 		odp_thrmask_clr(&thread_globals->control, thr);
+		thread_globals->num_control--;
+	}
 
 	thread_globals->num--;
 	return thread_globals->num;
@@ -192,3 +200,15 @@  int odp_cpu_id(void)
 {
 	return this_thread->cpu;
 }
+
+int odp_thrmask_worker(odp_thrmask_t *mask)
+{
+	odp_thrmask_copy(mask, &thread_globals->worker);
+	return thread_globals->num_worker;
+}
+
+int odp_thrmask_control(odp_thrmask_t *mask)
+{
+	odp_thrmask_copy(mask, &thread_globals->control);
+	return thread_globals->num_control;
+}