diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index 8be3568034..9953bf2933 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -808,7 +808,7 @@ void logClean (void) } } -extern volatile int oai_exit;//extern int oai_exit; +extern int oai_exit; void flush_mem_to_file(void) { int fp; diff --git a/executables/main-ocp.c b/executables/main-ocp.c index 5d949d5a28..3a1ad6ec19 100644 --- a/executables/main-ocp.c +++ b/executables/main-ocp.c @@ -71,7 +71,7 @@ pthread_cond_t sync_cond; pthread_mutex_t sync_mutex; int sync_var=-1; //!< protected by mutex \ref sync_mutex. int config_sync_var=-1; -volatile int oai_exit = 0; +int oai_exit = 0; double cpuf; THREAD_STRUCT thread_struct; diff --git a/executables/main_ru.c b/executables/main_ru.c index 93a580560e..3b1ce1116b 100644 --- a/executables/main_ru.c +++ b/executables/main_ru.c @@ -73,7 +73,7 @@ pthread_mutex_t sync_mutex; int sync_var=-1; //!< protected by mutex \ref sync_mutex. int config_sync_var=-1; -volatile int oai_exit = 0; +int oai_exit = 0; uint16_t sf_ahead = 4; RU_t ru_m; diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 2f75c2d295..baff757312 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -80,7 +80,7 @@ static int DEFBFW[] = {0x00007fff}; #include "nfapi_interface.h" #include -extern volatile int oai_exit; +extern int oai_exit; extern struct timespec timespec_sub(struct timespec lhs, struct timespec rhs); extern struct timespec timespec_add(struct timespec lhs, struct timespec rhs); diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h index 1e6c556acf..e4e4eee8ce 100644 --- a/executables/nr-softmodem-common.h +++ b/executables/nr-softmodem-common.h @@ -138,7 +138,7 @@ extern int rx_input_level_dBm; extern uint64_t num_missed_slots; // counter for the number of missed slots extern int oaisim_flag; -extern volatile int oai_exit; +extern int oai_exit; extern openair0_config_t openair0_cfg[MAX_CARDS]; extern pthread_cond_t sync_cond; diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 5a4ce42941..b8b2d7b038 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -93,7 +93,7 @@ int sync_var=-1; //!< protected by mutex \ref sync_mutex. int config_sync_var=-1; volatile int start_gNB = 0; -volatile int oai_exit = 0; +int oai_exit = 0; static int wait_for_sync = 0; diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index de3c108841..92dab90014 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -105,7 +105,7 @@ instance_t CUuniqInstance=0; instance_t DUuniqInstance=0; RAN_CONTEXT_t RC; -volatile int oai_exit = 0; +int oai_exit = 0; extern int16_t nr_dlsch_demod_shift; diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index a2ba680234..9c7108151e 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -283,7 +283,7 @@ extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; extern int usrp_tx_thread; extern uint16_t sl_ahead; extern uint16_t sf_ahead; -extern volatile int oai_exit; +extern int oai_exit; void tx_func(void *param); void rx_func(void *param); diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 13109d8f5a..a5aff0974e 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -59,7 +59,7 @@ uint64_t deadline, uint64_t period);*/ -extern volatile int oai_exit; +extern int oai_exit; void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) { int i, r, aa, layer; diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index fceff580a3..a6dde08a2c 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -44,7 +44,7 @@ #include extern WORKER_CONF_t get_thread_worker_conf(void); -extern volatile int oai_exit; +extern int oai_exit; diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h index c93e3a7de9..892fb7c864 100644 --- a/openair1/PHY/defs_common.h +++ b/openair1/PHY/defs_common.h @@ -982,13 +982,14 @@ typedef uint8_t(encoder_if_t)(uint8_t *input, uint8_t *output, uint8_t F); +extern int oai_exit; static inline void wait_sync(char *thread_name) { int rc; printf( "waiting for sync (%s,%d/%p,%p,%p)\n",thread_name,sync_var,&sync_var,&sync_cond,&sync_mutex); AssertFatal((rc = pthread_mutex_lock( &sync_mutex ))==0,"sync mutex lock error"); - while (sync_var<0) + while (sync_var<0 && !oai_exit) pthread_cond_wait( &sync_cond, &sync_mutex ); AssertFatal((rc = pthread_mutex_unlock( &sync_mutex ))==0,"sync mutex unlock error"); @@ -1011,7 +1012,7 @@ static inline int wakeup_thread(pthread_mutex_t *mutex, int sleep_cnt=0; AssertFatal((rc = pthread_mutex_lock(mutex))==0,"wakeup_thread(): error locking mutex for %s (%d %s, %p)\n", name, rc, strerror(rc), (void *)mutex); - while (*instance_cnt == 0) { + while (*instance_cnt == 0 && !oai_exit) { AssertFatal((rc = pthread_mutex_unlock(mutex))==0,"wakeup_thread(): error unlocking mutex for %s (%d %s, %p)\n", name, rc, strerror(rc), (void *)mutex); sleep_cnt++; @@ -1046,7 +1047,7 @@ static inline int timedwait_on_condition(pthread_mutex_t *mutex, struct timespec now, abstime; AssertFatal((rc = pthread_mutex_lock(mutex))==0,"[SCHED][eNB] timedwait_on_condition(): error locking mutex for %s (%d %s, %p)\n", name, rc, strerror(rc), (void *)mutex); - while (*instance_cnt < 0) { + while (*instance_cnt < 0 && !oai_exit) { clock_gettime(CLOCK_REALTIME, &now); // most of the time the thread is waiting here // proc->instance_cnt_rxtx is -1 @@ -1073,7 +1074,7 @@ static inline int wait_on_condition(pthread_mutex_t *mutex, int rc; AssertFatal((rc = pthread_mutex_lock(mutex))==0,"[SCHED][eNB] wait_on_condition(): error locking mutex for %s (%d %s, %p)\n", name, rc, strerror(rc), (void *)mutex); - while (*instance_cnt < 0) { + while (*instance_cnt < 0 && !oai_exit) { // most of the time the thread is waiting here // proc->instance_cnt_rxtx is -1 pthread_cond_wait(cond,mutex); // this unlocks mutex_rxtx while waiting and then locks it again @@ -1091,7 +1092,7 @@ static inline int wait_on_busy_condition(pthread_mutex_t *mutex, int rc; AssertFatal((rc = pthread_mutex_lock(mutex))==0,"[SCHED][eNB] wait_on_busy_condition(): error locking mutex for %s (%d %s, %p)\n", name, rc, strerror(rc), (void *)mutex); - while (*instance_cnt == 0) { + while (*instance_cnt == 0 && !oai_exit) { // most of the time the thread will skip this // waits only if proc->instance_cnt_rxtx is 0 pthread_cond_wait(cond,mutex); // this unlocks mutex_rxtx while waiting and then locks it again diff --git a/openair1/SIMULATION/LTE_PHY/unitary_defs.h b/openair1/SIMULATION/LTE_PHY/unitary_defs.h index 10a5366082..342fa18fb9 100644 --- a/openair1/SIMULATION/LTE_PHY/unitary_defs.h +++ b/openair1/SIMULATION/LTE_PHY/unitary_defs.h @@ -20,7 +20,7 @@ */ openair0_device openair0; -volatile int oai_exit=0; +int oai_exit=0; void exit_function(const char* file, const char* function, const int line,const char *s) { const char * msg= s==NULL ? "no comment": s; diff --git a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h index 805913d055..d3af2acd77 100644 --- a/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h +++ b/openair1/SIMULATION/NR_PHY/nr_unitary_defs.h @@ -33,7 +33,7 @@ #ifndef __NR_UNITARY_DEFS__H__ #define __NR_UNITARY_DEFS__H__ -volatile int oai_exit=0; +int oai_exit=0; void exit_function(const char* file, const char* function, const int line, const char *s) { const char * msg= s==NULL ? "no comment": s; diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 9adc6ecb5d..14a16f572b 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -134,7 +134,7 @@ notifiedFIFO_t pdcp_sdu_list; pdcp_enb_t pdcp_enb[MAX_NUM_CCs]; -extern volatile int oai_exit; +extern int oai_exit; pthread_t pdcp_stats_thread_desc; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 3d62d5c19a..b99d97a180 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -106,7 +106,7 @@ struct timing_info_t { // Fix per CC openair rf/if device update // extern openair0_device openair0; -extern volatile int oai_exit; +extern int oai_exit; extern int transmission_mode; diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 1d464cb90c..859a5c40a2 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -78,7 +78,7 @@ static int DEFBFW[] = {0x00007fff}; #define MBMS_EXPERIMENTAL -extern volatile int oai_exit; +extern int oai_exit; extern clock_source_t clock_source; #include "executables/thread-common.h" //extern PARALLEL_CONF_t get_thread_parallel_conf(void); diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 5d17cc17bb..b1275e5dd5 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -106,7 +106,7 @@ uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] -volatile int oai_exit = 0; +int oai_exit = 0; uint64_t downlink_frequency[MAX_NUM_CCs][4]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 38b71238b8..851c983290 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -146,7 +146,7 @@ extern int rx_input_level_dBm; extern uint64_t num_missed_slots; // counter for the number of missed slots extern int oaisim_flag; -extern volatile int oai_exit; +extern int oai_exit; extern openair0_config_t openair0_cfg[MAX_CARDS]; extern pthread_cond_t sync_cond; diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 05602b63da..963044a506 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -99,7 +99,7 @@ int config_sync_var=-1; uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] -volatile int oai_exit = 0; +int oai_exit = 0; unsigned int mmapped_dma=0;