From e5cd573ecb95eb71217b935e48c1248dcd8494a0 Mon Sep 17 00:00:00 2001
From: Sakthivel Velumani <velumani@eurecom.fr>
Date: Fri, 4 Dec 2020 15:10:58 +0100
Subject: [PATCH] Added a local variable instead of global

---
 executables/nr-gnb.c               | 5 ++++-
 executables/nr-softmodem.c         | 2 --
 openair1/SIMULATION/NR_PHY/dlsim.c | 1 -
 openair1/SIMULATION/NR_PHY/ulsim.c | 1 -
 openair2/GNB_APP/gnb_paramdef.h    | 7 +++++--
 5 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c
index 2f3c89f5e4..2c01d458ac 100644
--- a/executables/nr-gnb.c
+++ b/executables/nr-gnb.c
@@ -71,6 +71,7 @@
 #include "common/utils/LOG/vcd_signal_dumper.h"
 #include "UTIL/OPT/opt.h"
 #include "enb_config.h"
+#include "gnb_paramdef.h"
 
 
 #ifndef OPENAIR2
@@ -101,7 +102,6 @@ extern int transmission_mode;
 extern uint16_t sf_ahead;
 extern uint16_t sl_ahead;
 
-extern uint32_t num_threads_pusch;
 //pthread_t                       main_gNB_thread;
 
 time_stats_t softmodem_stats_mt; // main thread
@@ -872,6 +872,9 @@ void init_gNB_proc(int inst) {
   gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t));
   gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t));
   int numCPU = sysconf(_SC_NPROCESSORS_ONLN);
+  uint32_t num_threads_pusch;
+  paramdef_t PUSCHThreads[] = NUM_THREADS_DESC;
+  config_get( PUSCHThreads,sizeof(PUSCHThreads)/sizeof(paramdef_t),NULL);
   int threadCnt = min(numCPU, num_threads_pusch);
   char ul_pool[80];
   sprintf(ul_pool,"-1");
diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c
index adda039eaf..8271e66e2f 100644
--- a/executables/nr-softmodem.c
+++ b/executables/nr-softmodem.c
@@ -98,8 +98,6 @@ int config_sync_var=-1;
 volatile int             start_gNB = 0;
 volatile int             oai_exit = 0;
 
-uint32_t num_threads_pusch;
-
 static int wait_for_sync = 0;
 
 unsigned int mmapped_dma=0;
diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c
index f4b3e48ffc..f311e0eefa 100644
--- a/openair1/SIMULATION/NR_PHY/dlsim.c
+++ b/openair1/SIMULATION/NR_PHY/dlsim.c
@@ -75,7 +75,6 @@ rlc_info_t Rlc_info_um,Rlc_info_am_config;
 PHY_VARS_gNB *gNB;
 PHY_VARS_NR_UE *UE;
 RAN_CONTEXT_t RC;
-uint32_t num_threads_pusch;
 int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
 
 double cpuf;
diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c
index 43162e7e15..d924f7ef34 100644
--- a/openair1/SIMULATION/NR_PHY/ulsim.c
+++ b/openair1/SIMULATION/NR_PHY/ulsim.c
@@ -71,7 +71,6 @@ rlc_info_t Rlc_info_um,Rlc_info_am_config;
 PHY_VARS_gNB *gNB;
 PHY_VARS_NR_UE *UE;
 RAN_CONTEXT_t RC;
-uint32_t num_threads_pusch;
 int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
 
 int sf_ahead=4 ;
diff --git a/openair2/GNB_APP/gnb_paramdef.h b/openair2/GNB_APP/gnb_paramdef.h
index d892e667d4..ec1ee01b10 100644
--- a/openair2/GNB_APP/gnb_paramdef.h
+++ b/openair2/GNB_APP/gnb_paramdef.h
@@ -50,7 +50,6 @@
 
 extern int asn_debug;
 extern int asn1_xer_print;
-extern uint32_t num_threads_pusch;
 
 #ifdef LIBCONFIG_LONG
 #define libconfig_int long
@@ -91,9 +90,13 @@ typedef enum {
 /*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/
 #define GNBSPARAMS_DESC {                                                                                             \
 {GNB_CONFIG_STRING_ASN1_VERBOSITY,             NULL,     0,        uptr:NULL,   defstrval:GNB_CONFIG_STRING_ASN1_VERBOSITY_NONE,   TYPE_STRING,      0},   \
-{GNB_CONFIG_STRING_ACTIVE_GNBS,                NULL,     0,        uptr:NULL,   defstrval:NULL, 				   TYPE_STRINGLIST,  0},    \
+{GNB_CONFIG_STRING_ACTIVE_GNBS,                NULL,     0,        uptr:NULL,   defstrval:NULL, 				   TYPE_STRINGLIST,  0}    \
+}
+
+#define NUM_THREADS_DESC { \
 {GNB_CONFIG_PUSCH_THREADS,                     NULL,     0,        uptr:&num_threads_pusch,   defuintval:1, 				   TYPE_UINT,  0}    \
 }
+
 #define GNB_ASN1_VERBOSITY_IDX                     0
 #define GNB_ACTIVE_GNBS_IDX                        1
 
-- 
2.26.2