Commit de32c389 authored by Wang Tsu-Han's avatar Wang Tsu-Han

applying new mechanism for communication between threads

parent 2104817a
...@@ -162,7 +162,7 @@ extern void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset); ...@@ -162,7 +162,7 @@ extern void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset);
static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_name) { static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_name) {
start_meas(&softmodem_stats_rxtx_sf); start_meas(&softmodem_stats_rxtx_sf);
eNB_rxtx_proc_t *L1_proc_tx = &eNB->proc.L1_proc_tx; //eNB_rxtx_proc_t *L1_proc_tx = &eNB->proc.L1_proc_tx;
// ******************************************************************* // *******************************************************************
...@@ -223,14 +223,30 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam ...@@ -223,14 +223,30 @@ 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 ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 1 );
//#TODO /*//#TODO
if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT){ if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT)
if(wait_on_condition(&L1_proc_tx->mutex,&L1_proc_tx->cond,&L1_proc_tx->instance_cnt,"wakeup_tx")<0) { {
LOG_E(PHY,"Frame %d, subframe %d: TX1 not ready\n",L1_proc_tx->frame_rx,L1_proc_tx->subframe_rx); if (pthread_mutex_lock(mutex) != 0) {
LOG_E(PHY, "[SCHED][eNB] ERROR locking mutex for eNB L1_thread_tx\n");
exit_fun("ERROR pthread_lock");
return(-1);
}
while(L1_proc_tx->instance_cnt == 0){
pthread_cond_wait(L1_proc_tx->cond,L1_proc_tx->mutex);
}
L1_proc_tx->instance_cnt = 0;
if (pthread_cond_signal(&L1_proc_tx->cond) != 0) {
LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB L1_thread_tx\n");
exit_fun( "ERROR pthread_cond_signal" );
return(-1); return(-1);
} }
if (release_thread(&L1_proc_tx->mutex,&L1_proc_tx->instance_cnt,"wakeup_tx")<0) return(-1); if (pthread_mutex_unlock(mutex) != 0) {
LOG_E(PHY,"[SCHED][eNB] error unlocking mutex for %s\n",name);
exit_fun("ERROR pthread_unlock");
return(-1);
} }
}*/
pthread_mutex_lock(&eNB->UL_INFO_mutex); pthread_mutex_lock(&eNB->UL_INFO_mutex);
...@@ -331,18 +347,16 @@ static void* L1_thread_tx(void* param) { ...@@ -331,18 +347,16 @@ static void* L1_thread_tx(void* param) {
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX1_ENB,proc->frame_rx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX1_ENB,proc->frame_rx);
phy_procedures_eNB_TX(eNB, proc, 1); phy_procedures_eNB_TX(eNB, proc, 1);
if (release_thread(&proc->mutex,&proc->instance_cnt,thread_name)<0) break;
//#TODO
pthread_mutex_lock( &proc->mutex ); pthread_mutex_lock( &proc->mutex );
proc->instance_cnt++; proc->instance_cnt = -1;
// the thread can now be woken up // the thread can now be woken up
if (pthread_cond_signal(&proc->cond) != 0) { if (pthread_cond_signal(&proc->cond) != 0) {
LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n");
exit_fun( "ERROR pthread_cond_signal" ); exit_fun( "ERROR pthread_cond_signal" );
} }
pthread_mutex_unlock( &proc->mutex ); pthread_mutex_unlock( &proc->mutex );
wakeup_txfh(proc,eNB_proc->ru_proc); wakeup_txfh(proc,eNB->proc.ru_proc);
} }
return 0; return 0;
...@@ -414,14 +428,6 @@ static void* L1_thread( void* param ) { ...@@ -414,14 +428,6 @@ static void* L1_thread( void* param ) {
} }
if (release_thread(&proc->mutex,&proc->instance_cnt,thread_name)<0) break; if (release_thread(&proc->mutex,&proc->instance_cnt,thread_name)<0) break;
pthread_mutex_lock( &proc->mutex);
proc->instance_cnt++;
// the thread can now be woken up
if (pthread_cond_signal(&proc->cond) != 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 );
if (nfapi_mode!=2){ if (nfapi_mode!=2){
if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) wakeup_tx(eNB,eNB->proc.ru_proc); if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) wakeup_tx(eNB,eNB->proc.ru_proc);
else if(get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT) else if(get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT)
...@@ -474,13 +480,13 @@ int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc) { ...@@ -474,13 +480,13 @@ int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc) {
struct timespec wait; struct timespec wait;
wait.tv_sec=0; wait.tv_sec=0;
wait.tv_nsec=5000000L; wait.tv_nsec=5000000L;
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~inside wakeup_txfh %d.%d IC_RU = %d\n", proc->frame_tx, proc->subframe_tx, proc->instance_cnt_RUs);
if(wait_on_condition(&proc->mutex_RUs,&proc->cond_RUs,&proc->instance_cnt_RUs,"wakeup_txfh")<0) {
if(wait_on_condition(&ru_proc->mutex_eNBs,&ru_proc->cond_eNBs,&ru_proc->ru_tx_ready,"wakeup_txfh")<0) {
LOG_E(PHY,"Frame %d, subframe %d: TX FH not ready\n", ru_proc->frame_tx, ru_proc->subframe_tx); LOG_E(PHY,"Frame %d, subframe %d: TX FH not ready\n", ru_proc->frame_tx, ru_proc->subframe_tx);
return(-1); return(-1);
} }
if (release_thread(&ru_proc->mutex_eNBs,&ru_proc->ru_tx_ready,"wakeup_txfh")<0) return(-1); if (release_thread(&proc->mutex_RUs,&proc->instance_cnt_RUs,"wakeup_txfh")<0) return(-1);
if (ru_proc->instance_cnt_eNBs == 0) { if (ru_proc->instance_cnt_eNBs == 0) {
LOG_E(PHY,"Frame %d, subframe %d: TX FH thread busy, dropping Frame %d, subframe %d\n", ru_proc->frame_tx, ru_proc->subframe_tx, proc->frame_rx, proc->subframe_rx); LOG_E(PHY,"Frame %d, subframe %d: TX FH thread busy, dropping Frame %d, subframe %d\n", ru_proc->frame_tx, ru_proc->subframe_tx, proc->frame_rx, proc->subframe_rx);
...@@ -492,11 +498,13 @@ int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc) { ...@@ -492,11 +498,13 @@ int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc) {
return(-1); return(-1);
} }
++ru_proc->instance_cnt_eNBs; //for(num_RUs)
ru_proc->instance_cnt_eNBs = 0;
ru_proc->timestamp_tx = proc->timestamp_tx; ru_proc->timestamp_tx = proc->timestamp_tx;
ru_proc->subframe_tx = proc->subframe_tx; ru_proc->subframe_tx = proc->subframe_tx;
ru_proc->frame_tx = proc->frame_tx; ru_proc->frame_tx = proc->frame_tx;
// the thread can now be woken up // the thread can now be woken up
if (pthread_cond_signal(&ru_proc->cond_eNBs) != 0) { if (pthread_cond_signal(&ru_proc->cond_eNBs) != 0) {
LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n");
...@@ -522,19 +530,16 @@ int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { ...@@ -522,19 +530,16 @@ int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) {
wait.tv_nsec=5000000L; wait.tv_nsec=5000000L;
if (L1_proc_tx->instance_cnt == 0) {
LOG_E(PHY,"Frame %d, subframe %d: TX1 thread busy, dropping\n",L1_proc_tx->frame_rx,L1_proc_tx->subframe_rx);
return(-1);
}
if (pthread_mutex_timedlock(&L1_proc_tx->mutex,&wait) != 0) { if (pthread_mutex_timedlock(&L1_proc_tx->mutex,&wait) != 0) {
LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX1 thread %d (IC %d)\n", L1_proc_tx->subframe_rx&1,L1_proc_tx->instance_cnt ); LOG_E(PHY, "[SCHED][eNB] ERROR locking mutex for eNB L1_thread_tx\n");
exit_fun( "error locking mutex_tx" ); exit_fun("ERROR pthread_lock");
return(-1); return(-1);
} }
while(L1_proc_tx->instance_cnt == 0){
pthread_cond_wait(&L1_proc_tx->cond,&L1_proc_tx->mutex);
}
++L1_proc_tx->instance_cnt; L1_proc_tx->instance_cnt = 0;
L1_proc_tx->subframe_rx = L1_proc->subframe_rx; L1_proc_tx->subframe_rx = L1_proc->subframe_rx;
...@@ -899,6 +904,8 @@ void init_eNB_proc(int inst) { ...@@ -899,6 +904,8 @@ void init_eNB_proc(int inst) {
L1_proc_tx = &proc->L1_proc_tx; L1_proc_tx = &proc->L1_proc_tx;
L1_proc->instance_cnt = -1; L1_proc->instance_cnt = -1;
L1_proc_tx->instance_cnt = -1; L1_proc_tx->instance_cnt = -1;
L1_proc->instance_cnt_RUs = 0;
L1_proc_tx->instance_cnt_RUs = 0;
proc->instance_cnt_prach = -1; proc->instance_cnt_prach = -1;
proc->instance_cnt_asynch_rxtx = -1; proc->instance_cnt_asynch_rxtx = -1;
proc->instance_cnt_synch = -1; proc->instance_cnt_synch = -1;
...@@ -914,6 +921,10 @@ void init_eNB_proc(int inst) { ...@@ -914,6 +921,10 @@ void init_eNB_proc(int inst) {
pthread_mutex_init( &L1_proc_tx->mutex, NULL); pthread_mutex_init( &L1_proc_tx->mutex, NULL);
pthread_cond_init( &L1_proc->cond, NULL); pthread_cond_init( &L1_proc->cond, NULL);
pthread_cond_init( &L1_proc_tx->cond, NULL); pthread_cond_init( &L1_proc_tx->cond, NULL);
pthread_mutex_init( &L1_proc->mutex_RUs, NULL);
pthread_mutex_init( &L1_proc_tx->mutex_RUs, NULL);
pthread_cond_init( &L1_proc->cond_RUs, NULL);
pthread_cond_init( &L1_proc_tx->cond_RUs, NULL);
pthread_mutex_init( &proc->mutex_prach, NULL); pthread_mutex_init( &proc->mutex_prach, NULL);
pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL); pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL);
...@@ -1009,7 +1020,7 @@ void kill_eNB_proc(int inst) { ...@@ -1009,7 +1020,7 @@ void kill_eNB_proc(int inst) {
PHY_VARS_eNB *eNB; PHY_VARS_eNB *eNB;
eNB_proc_t *proc; eNB_proc_t *proc;
eNB_rxtx_proc_t *L1_proc, *L1_proc_tx; eNB_rxtx_proc_t *L1_proc, *L1_proc_tx;
int i;
for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
eNB=RC.eNB[inst][CC_id]; eNB=RC.eNB[inst][CC_id];
......
...@@ -1249,12 +1249,12 @@ void do_ru_synch(RU_t *ru) { ...@@ -1249,12 +1249,12 @@ void do_ru_synch(RU_t *ru) {
void wakeup_eNBs(RU_t *ru) { void wakeup_L1s(RU_t *ru) {
int i; int i;
PHY_VARS_eNB **eNB_list = ru->eNB_list; PHY_VARS_eNB **eNB_list = ru->eNB_list;
LOG_D(PHY,"wakeup_eNBs (num %d) for RU %d ru->eNB_top:%p\n",ru->num_eNB,ru->idx, ru->eNB_top); LOG_D(PHY,"wakeup_L1s (num %d) for RU %d ru->eNB_top:%p\n",ru->num_eNB,ru->idx, ru->eNB_top);
if (ru->num_eNB==1 && ru->eNB_top!=0 && get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD) { if (ru->num_eNB==1 && ru->eNB_top!=0 && get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD) {
...@@ -1531,6 +1531,10 @@ volatile int16_t phy_tx_end; ...@@ -1531,6 +1531,10 @@ volatile int16_t phy_tx_end;
static void* ru_thread_tx( void* param ) { static void* ru_thread_tx( void* param ) {
RU_t *ru = (RU_t*)param; RU_t *ru = (RU_t*)param;
RU_proc_t *proc = &ru->proc; RU_proc_t *proc = &ru->proc;
PHY_VARS_eNB *eNB;
eNB_proc_t *eNB_proc;
eNB_rxtx_proc_t *L1_proc;
cpu_set_t cpuset; cpu_set_t cpuset;
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
...@@ -1555,6 +1559,7 @@ static void* ru_thread_tx( void* param ) { ...@@ -1555,6 +1559,7 @@ static void* ru_thread_tx( void* param ) {
// wait until eNBs are finished subframe RX n and TX n+4 // 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"); wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx");
if (oai_exit) break; if (oai_exit) break;
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~ru_thread_tx is waken up %d.%d having L1 %d\n", proc->frame_tx, proc->subframe_tx, ru->num_eNB);
// do TX front-end processing if needed (precoding and/or IDFTs) // do TX front-end processing if needed (precoding and/or IDFTs)
if (ru->feptx_prec) ru->feptx_prec(ru); if (ru->feptx_prec) ru->feptx_prec(ru);
...@@ -1568,15 +1573,22 @@ static void* ru_thread_tx( void* param ) { ...@@ -1568,15 +1573,22 @@ static void* ru_thread_tx( void* param ) {
if (ru->fh_north_out) ru->fh_north_out(ru); if (ru->fh_north_out) ru->fh_north_out(ru);
} }
release_thread(&proc->mutex_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); release_thread(&proc->mutex_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx");
for(int i = 0; i<ru->num_eNB; i++)
pthread_mutex_lock( &proc->mutex_eNBs ); {
proc->ru_tx_ready++; eNB = ru->eNB_list[i];
eNB_proc = &eNB->proc;
L1_proc = (get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT)? &eNB_proc->L1_proc_tx : &eNB_proc->L1_proc;
char *L1_proc_name = (get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT)? "L1_proc_tx" : "L1_proc";
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~ru_thread_tx signaling to eNB_list[%d] with %s IC_RU %d\n", i, L1_proc_name, L1_proc->instance_cnt_RUs);
pthread_mutex_lock( &L1_proc->mutex_RUs );
L1_proc->instance_cnt_RUs = 0;
// the thread can now be woken up // the thread can now be woken up
if (pthread_cond_signal(&proc->cond_eNBs) != 0) { if (pthread_cond_signal(&L1_proc->cond_RUs) != 0) {
LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n");
exit_fun( "ERROR pthread_cond_signal" ); exit_fun( "ERROR pthread_cond_signal" );
} }
pthread_mutex_unlock( &proc->mutex_eNBs ); pthread_mutex_unlock( &L1_proc->mutex_RUs );
}
} }
release_thread(&proc->mutex_FH1,&proc->instance_cnt_FH1,"ru_thread_tx"); release_thread(&proc->mutex_FH1,&proc->instance_cnt_FH1,"ru_thread_tx");
return 0; return 0;
...@@ -1785,7 +1797,7 @@ static void* ru_thread( void* param ) { ...@@ -1785,7 +1797,7 @@ static void* ru_thread( void* param ) {
#endif #endif
// wakeup all eNB processes waiting for this RU // wakeup all eNB processes waiting for this RU
if (ru->num_eNB>0) wakeup_eNBs(ru); if (ru->num_eNB>0) wakeup_L1s(ru);
#ifndef PHY_TX_THREAD #ifndef PHY_TX_THREAD
if(get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD || ru->num_eNB==0){ if(get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD || ru->num_eNB==0){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment