From f55a4dd8e0e413c60a54f3ea1dfeb99b08e440cb Mon Sep 17 00:00:00 2001
From: Sakthivel Velumani <velumani@eurecom.fr>
Date: Mon, 23 Nov 2020 16:45:59 +0100
Subject: [PATCH] Remove hard-coding of no of threads Script added to set the
 no of threads according to run-time conditions of the machine.

---
 executables/nr-gnb.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c
index 7f01ce6745..1a7a6aa373 100644
--- a/executables/nr-gnb.c
+++ b/executables/nr-gnb.c
@@ -869,7 +869,14 @@ void init_gNB_proc(int inst) {
 
   gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t));
   gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t));
-  char ul_pool[] = "-1,-1";
+  int numCPU = sysconf(_SC_NPROCESSORS_ONLN);
+  char ul_pool[80];
+  sprintf(ul_pool,"%d",1);
+  int s_offset = 0;
+  for (int icpu=2; icpu<numCPU; icpu++) {
+    sprintf(ul_pool+1+s_offset,",%d",icpu);
+    s_offset += 2;
+  }
   initTpool(ul_pool, gNB->threadPool, false);
   initNotifiedFIFO(gNB->respDecode);
 }
-- 
2.26.2