Commit 1512e39e authored by Robert Schmidt's avatar Robert Schmidt

Rewrite kill_NR_RU_proc() and reuse functions

parent 9ec3deb5
......@@ -1331,40 +1331,26 @@ void init_RU_proc(RU_t *ru) {
}
void kill_NR_RU_proc(int inst) {
RU_t *ru = RC.ru[inst];
RU_proc_t *proc = &ru->proc;
LOG_D(PHY, "Joining pthread_FH\n");
/* Note: it seems pthread_FH and and FEP thread below both use
* mutex_fep/cond_fep. Thus, we unlocked above for pthread_FH above and do
* the same for FEP thread below again (using broadcast() to ensure both
* threads get the signal). This one will also destroy the mutex and cond. */
pthread_mutex_lock(&proc->mutex_fep);
proc->instance_cnt_fep = 0;
pthread_cond_broadcast(&proc->cond_fep);
pthread_mutex_unlock( &proc->mutex_fep );
pthread_join(proc->pthread_FH, NULL);
if (get_nprocs() >= 2) {
if (ru->feprx) {
pthread_mutex_lock(&proc->mutex_fep);
proc->instance_cnt_fep = 0;
pthread_mutex_unlock(&proc->mutex_fep);
pthread_cond_signal(&proc->cond_fep);
LOG_D(PHY, "Joining pthread_fep\n");
pthread_join(proc->pthread_fep, NULL);
pthread_mutex_destroy(&proc->mutex_fep);
pthread_cond_destroy(&proc->cond_fep);
}
if (ru->feprx)
nr_kill_feprx_thread(ru);
if (ru->feptx_ofdm) {
pthread_mutex_lock(&proc->mutex_feptx);
proc->instance_cnt_feptx = 0;
pthread_mutex_unlock(&proc->mutex_feptx);
pthread_cond_signal(&proc->cond_feptx);
LOG_D(PHY, "Joining pthread_feptx\n");
pthread_join(proc->pthread_feptx, NULL);
pthread_mutex_destroy(&proc->mutex_feptx);
pthread_cond_destroy(&proc->cond_feptx);
}
}
if (opp_enabled) {
LOG_D(PHY, "Joining ru_stats_thread\n");
pthread_join(ru->ru_stats_thread, NULL);
}
if (ru->feptx_ofdm)
nr_kill_feptx_thread(ru);
}
int check_capabilities(RU_t *ru,RRU_capabilities_t *cap) {
......
......@@ -453,6 +453,24 @@ void nr_init_feptx_thread(RU_t *ru) {
}
void nr_kill_feptx_thread(RU_t *ru) {
RU_proc_t *proc = &ru->proc;
for (int i = 0; i < ru->nb_tx * 2; i++) {
RU_feptx_t *feptx = &proc->feptx[i];
if (feptx->pthread_feptx == 0)
continue;
pthread_mutex_lock(&feptx->mutex_feptx);
feptx->instance_cnt_feptx = 0;
pthread_mutex_unlock(&feptx->mutex_feptx);
pthread_cond_signal(&feptx->cond_feptx);
LOG_I(PHY, "Joining pthread_feptx %d\n", i);
pthread_join(feptx->pthread_feptx, NULL);
pthread_mutex_destroy(&feptx->mutex_feptx);
pthread_cond_destroy(&feptx->cond_feptx);
}
}
void nr_feptx_prec(RU_t *ru,int frame_tx,int tti_tx) {
......@@ -590,6 +608,19 @@ void nr_init_feprx_thread(RU_t *ru) {
threadCreate(&proc->pthread_fep, nr_feprx_thread, (void*)ru, "feprx", -1, OAI_PRIORITY_RT);
}
void nr_kill_feprx_thread(RU_t *ru) {
RU_proc_t *proc = &ru->proc;
if (proc->pthread_fep == 0)
return;
LOG_I(PHY, "Joining pthread_feprx\n");
pthread_mutex_lock(&proc->mutex_fep);
proc->instance_cnt_fep = 0;
pthread_mutex_unlock(&proc->mutex_fep);
pthread_cond_signal(&proc->cond_fep);
pthread_join(proc->pthread_fep, NULL);
pthread_mutex_destroy(&proc->mutex_fep);
pthread_cond_destroy(&proc->cond_fep);
}
void nr_fep_full_2thread(RU_t *ru, int slot) {
......
......@@ -45,11 +45,13 @@ void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx);
void nr_feptx_ofdm_2thread(RU_t *ru,int frame_tx,int tti_tx);
void nr_feptx0(RU_t *ru,int tti_tx,int first_symbol, int num_symbols, int aa);
void nr_init_feptx_thread(RU_t *ru);
void nr_kill_feptx_thread(RU_t *ru);
void fep_full(RU_t *ru,int slot);
void nr_feptx_prec(RU_t *ru,int frame_tx,int tti_tx);
void nr_init_feptx_prec_thread(RU_t *ru);
void nr_feptx_prec_control(RU_t *ru,int frame,int tti_tx);
void nr_init_feprx_thread(RU_t *ru);
void nr_kill_feprx_thread(RU_t *ru);
void nr_fep_full(RU_t *ru, int slot);
void nr_fep_full_2thread(RU_t *ru, int slot);
void feptx_prec(RU_t *ru,int frame_tx,int tti_tx);
......
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