From 68fdd19cb7e73447b6c4923d63d215c41f173b46 Mon Sep 17 00:00:00 2001
From: WANG Tsu-Han <wangts@eurecom.fr>
Date: Wed, 11 Apr 2018 15:09:07 +0200
Subject: [PATCH] fixs for 5-7 core

---
 targets/RT/USER/lte-enb.c | 26 ++++++--------------------
 targets/RT/USER/lte-ru.c  |  1 +
 2 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c
index d12cb3edb2..7dcfd432de 100644
--- a/targets/RT/USER/lte-enb.c
+++ b/targets/RT/USER/lte-enb.c
@@ -224,11 +224,13 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam
   }
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 1 );
 
-  if(wait_on_condition(&proc[1].mutex_rxtx,&proc[1].cond_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0) {
-    LOG_E(PHY,"Frame %d, subframe %d: TX1 not ready\n",proc[1].frame_rx,proc[1].subframe_rx);
-    return(-1);
+  if(get_nprocs() >= 8){
+    if(wait_on_condition(&proc[1].mutex_rxtx,&proc[1].cond_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0) {
+      LOG_E(PHY,"Frame %d, subframe %d: TX1 not ready\n",proc[1].frame_rx,proc[1].subframe_rx);
+      return(-1);
+    }
+    if (release_thread(&proc[1].mutex_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0)  return(-1);
   }
-  if (release_thread(&proc[1].mutex_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0)  return(-1);
 
   pthread_mutex_lock(&eNB->UL_INFO_mutex);
 
@@ -245,14 +247,6 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam
   if(oai_exit) return(-1);
   if(get_nprocs() <= 4){
     phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1);
-    pthread_mutex_lock( &proc[1].mutex_rxtx );
-    proc[1].pipe_ready++;
-    // the thread can now be woken up
-    if (pthread_cond_signal(&proc[1].cond_rxtx) != 0) {
-      LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n");
-      exit_fun( "ERROR pthread_cond_signal" );
-    }
-    pthread_mutex_unlock( &proc[1].mutex_rxtx );
   }
 
 
@@ -417,14 +411,6 @@ static void* eNB_thread_rxtx( void* param ) {
     else
     {  
       phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1);
-      pthread_mutex_lock( &proc[1].mutex_rxtx );
-      proc[1].pipe_ready++;
-      // the thread can now be woken up
-      if (pthread_cond_signal(&proc[1].cond_rxtx) != 0) {
-        LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n");
-        exit_fun( "ERROR pthread_cond_signal" );
-      }
-      pthread_mutex_unlock( &proc->mutex_rxtx );
       wakeup_txfh(proc,eNB->proc.ru_proc);
     }
 
diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c
index c634a12bb8..bcc0e1c014 100644
--- a/targets/RT/USER/lte-ru.c
+++ b/targets/RT/USER/lte-ru.c
@@ -1463,6 +1463,7 @@ static void* ru_thread_tx( void* param ) {
 	LOG_D(PHY,"ru_thread_tx: Waiting for TX processing\n");
 	// wait until eNBs are finished subframe RX n and TX n+4
     wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx");
+    if (oai_exit) break;
   	       
     // do TX front-end processing if needed (precoding and/or IDFTs)
     if (ru->feptx_prec) ru->feptx_prec(ru);
-- 
GitLab