Commit 3ca319c0 authored by Wang Tsu-Han's avatar Wang Tsu-Han

adding te/td distructure

parent b0c11269
...@@ -489,7 +489,7 @@ typedef struct eNB_proc_t_s { ...@@ -489,7 +489,7 @@ typedef struct eNB_proc_t_s {
/// \internal This variable is protected by \ref mutex_td. /// \internal This variable is protected by \ref mutex_td.
int instance_cnt_td; int instance_cnt_td;
/// \internal This variable is protected by \ref mutex_te. /// \internal This variable is protected by \ref mutex_te.
int instance_cnt_te[3]; //int instance_cnt_te[3];
/// \internal This variable is protected by \ref mutex_prach. /// \internal This variable is protected by \ref mutex_prach.
int instance_cnt_prach; int instance_cnt_prach;
#ifdef Rel14 #ifdef Rel14
...@@ -511,7 +511,7 @@ typedef struct eNB_proc_t_s { ...@@ -511,7 +511,7 @@ typedef struct eNB_proc_t_s {
/// pthread attributes for parallel turbo-decoder thread /// pthread attributes for parallel turbo-decoder thread
pthread_attr_t attr_td; pthread_attr_t attr_td;
/// pthread attributes for parallel turbo-encoder thread /// pthread attributes for parallel turbo-encoder thread
pthread_attr_t attr_te[3]; //pthread_attr_t attr_te[3];
/// pthread attributes for single eNB processing thread /// pthread attributes for single eNB processing thread
pthread_attr_t attr_single; pthread_attr_t attr_single;
/// pthread attributes for prach processing thread /// pthread attributes for prach processing thread
...@@ -525,7 +525,7 @@ typedef struct eNB_proc_t_s { ...@@ -525,7 +525,7 @@ typedef struct eNB_proc_t_s {
/// scheduling parameters for parallel turbo-decoder thread /// scheduling parameters for parallel turbo-decoder thread
struct sched_param sched_param_td; struct sched_param sched_param_td;
/// scheduling parameters for parallel turbo-encoder thread /// scheduling parameters for parallel turbo-encoder thread
struct sched_param sched_param_te[3]; //struct sched_param sched_param_te[3];
/// scheduling parameters for single eNB thread /// scheduling parameters for single eNB thread
struct sched_param sched_param_single; struct sched_param sched_param_single;
/// scheduling parameters for prach thread /// scheduling parameters for prach thread
...@@ -539,7 +539,7 @@ typedef struct eNB_proc_t_s { ...@@ -539,7 +539,7 @@ typedef struct eNB_proc_t_s {
/// pthread structure for parallel turbo-decoder thread /// pthread structure for parallel turbo-decoder thread
pthread_t pthread_td; pthread_t pthread_td;
/// pthread structure for parallel turbo-encoder thread /// pthread structure for parallel turbo-encoder thread
pthread_t pthread_te[3]; //pthread_t pthread_te[3];
/// pthread structure for PRACH thread /// pthread structure for PRACH thread
pthread_t pthread_prach; pthread_t pthread_prach;
#ifdef Rel14 #ifdef Rel14
...@@ -549,7 +549,7 @@ typedef struct eNB_proc_t_s { ...@@ -549,7 +549,7 @@ typedef struct eNB_proc_t_s {
/// condition variable for parallel turbo-decoder thread /// condition variable for parallel turbo-decoder thread
pthread_cond_t cond_td; pthread_cond_t cond_td;
/// condition variable for parallel turbo-encoder thread /// condition variable for parallel turbo-encoder thread
pthread_cond_t cond_te[3]; //pthread_cond_t cond_te[3];
/// condition variable for PRACH processing thread; /// condition variable for PRACH processing thread;
pthread_cond_t cond_prach; pthread_cond_t cond_prach;
#ifdef Rel14 #ifdef Rel14
...@@ -561,7 +561,7 @@ typedef struct eNB_proc_t_s { ...@@ -561,7 +561,7 @@ typedef struct eNB_proc_t_s {
/// mutex for parallel turbo-decoder thread /// mutex for parallel turbo-decoder thread
pthread_mutex_t mutex_td; pthread_mutex_t mutex_td;
/// mutex for parallel turbo-encoder thread /// mutex for parallel turbo-encoder thread
pthread_mutex_t mutex_te[3]; //pthread_mutex_t mutex_te[3];
/// mutex for PRACH thread /// mutex for PRACH thread
pthread_mutex_t mutex_prach; pthread_mutex_t mutex_prach;
#ifdef Rel14 #ifdef Rel14
......
...@@ -1494,18 +1494,29 @@ extern int oai_exit; ...@@ -1494,18 +1494,29 @@ extern int oai_exit;
extern void *td_thread(void*); extern void *td_thread(void*);
void init_td_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_td) { void init_td_thread(PHY_VARS_eNB *eNB) {
eNB_proc_t *proc = &eNB->proc; eNB_proc_t *proc = &eNB->proc;
proc->tdp.eNB = eNB; proc->tdp.eNB = eNB;
proc->instance_cnt_td = -1; proc->instance_cnt_td = -1;
pthread_attr_init( &proc->attr_td);
pthread_mutex_init( &proc->mutex_td, NULL); pthread_mutex_init( &proc->mutex_td, NULL);
pthread_cond_init( &proc->cond_td, NULL); pthread_cond_init( &proc->cond_td, NULL);
pthread_create(&proc->pthread_td, &proc->attr_td, td_thread, (void*)&proc->tdp);
pthread_create(&proc->pthread_td, attr_td, td_thread, (void*)&proc->tdp); }
void kill_td_thread(PHY_VARS_eNB *eNB) {
eNB_proc_t *proc = &eNB->proc;
proc->instance_cnt_td = 0;
pthread_cond_signal(&proc->cond_td);
pthread_join(proc->pthread_td, NULL);
pthread_mutex_destroy( &proc->mutex_td );
pthread_cond_destroy( &proc->cond_td );
} }
extern void *te_thread(void*); extern void *te_thread(void*);
...@@ -1514,37 +1525,29 @@ void init_te_thread(PHY_VARS_eNB *eNB) { ...@@ -1514,37 +1525,29 @@ void init_te_thread(PHY_VARS_eNB *eNB) {
eNB_proc_t *proc = &eNB->proc; eNB_proc_t *proc = &eNB->proc;
proc->tep[0].eNB = eNB; for(int i=0; i<3 ;i++){
proc->tep[0].instance_cnt_te = -1; proc->tep[i].eNB = eNB;
proc->tep[i].instance_cnt_te = -1;
pthread_mutex_init( &proc->tep[0].mutex_te, NULL);
pthread_cond_init( &proc->tep[0].cond_te, NULL); pthread_mutex_init( &proc->tep[i].mutex_te, NULL);
pthread_attr_init( &proc->tep[0].attr_te); pthread_cond_init( &proc->tep[i].cond_te, NULL);
pthread_attr_init( &proc->tep[i].attr_te);
printf("Creating te_thread 0\n");
pthread_create(&proc->tep[0].pthread_te, &proc->tep[0].attr_te, te_thread, (void*)&proc->tep[0]);
/////////////////////////////////////////////////////////////////////////
proc->tep[1].eNB = eNB;
proc->tep[1].instance_cnt_te = -1;
pthread_mutex_init( &proc->tep[1].mutex_te, NULL); printf("Creating te_thread 0\n");
pthread_cond_init( &proc->tep[1].cond_te, NULL); pthread_create(&proc->tep[i].pthread_te, &proc->tep[i].attr_te, te_thread, (void*)&proc->tep[i]);
pthread_attr_init( &proc->tep[1].attr_te); }
}
void kill_te_thread(PHY_VARS_eNB *eNB) {
printf("Creating te_thread 1\n"); eNB_proc_t *proc = &eNB->proc;
pthread_create(&proc->tep[1].pthread_te, &proc->tep[1].attr_te, te_thread, (void*)&proc->tep[1]);
/////////////////////////////////////////////////////////////////////////
proc->tep[2].eNB = eNB;
proc->tep[2].instance_cnt_te = -1;
pthread_mutex_init( &proc->tep[2].mutex_te, NULL);
pthread_cond_init( &proc->tep[2].cond_te, NULL);
pthread_attr_init( &proc->tep[2].attr_te);
printf("Creating te_thread 2\n"); for(int i=0; i<3 ;i++){
pthread_create(&proc->tep[2].pthread_te, &proc->tep[2].attr_te, te_thread, (void*)&proc->tep[2]); proc->tep[i].instance_cnt_te = 0;
pthread_cond_signal(&proc->tep[i].cond_te);
pthread_join(proc->tep[i].pthread_te, NULL);
pthread_mutex_init( &proc->tep[i].mutex_te, NULL);
pthread_cond_init( &proc->tep[i].cond_te, NULL);
}
} }
......
...@@ -756,8 +756,10 @@ static void* eNB_thread_prach_br( void* param ) { ...@@ -756,8 +756,10 @@ static void* eNB_thread_prach_br( void* param ) {
extern void init_td_thread(PHY_VARS_eNB *, pthread_attr_t *); extern void init_td_thread(PHY_VARS_eNB *);
extern void init_te_thread(PHY_VARS_eNB *); extern void init_te_thread(PHY_VARS_eNB *);
extern void kill_td_thread(PHY_VARS_eNB *);
extern void kill_te_thread(PHY_VARS_eNB *);
//////////////////////////////////////need to modified////////////////***** //////////////////////////////////////need to modified////////////////*****
static void* process_stats_thread(void* param) { static void* process_stats_thread(void* param) {
...@@ -795,7 +797,7 @@ void init_eNB_proc(int inst) { ...@@ -795,7 +797,7 @@ void init_eNB_proc(int inst) {
PHY_VARS_eNB *eNB; PHY_VARS_eNB *eNB;
eNB_proc_t *proc; eNB_proc_t *proc;
eNB_rxtx_proc_t *proc_rxtx; eNB_rxtx_proc_t *proc_rxtx;
pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL,*attr_td=NULL;//,*attr_te=NULL,*attr_te1=NULL; pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL;
#ifdef Rel14 #ifdef Rel14
pthread_attr_t *attr_prach_br=NULL; pthread_attr_t *attr_prach_br=NULL;
#endif #endif
...@@ -838,9 +840,6 @@ void init_eNB_proc(int inst) { ...@@ -838,9 +840,6 @@ void init_eNB_proc(int inst) {
pthread_attr_init( &proc->attr_prach); pthread_attr_init( &proc->attr_prach);
pthread_attr_init( &proc->attr_asynch_rxtx); pthread_attr_init( &proc->attr_asynch_rxtx);
pthread_attr_init( &proc->attr_td);
//pthread_attr_init( &proc->attr_te[0]);
//pthread_attr_init( &proc->attr_te[1]);
pthread_attr_init( &proc_rxtx[0].attr_rxtx); pthread_attr_init( &proc_rxtx[0].attr_rxtx);
pthread_attr_init( &proc_rxtx[1].attr_rxtx); pthread_attr_init( &proc_rxtx[1].attr_rxtx);
#ifdef Rel14 #ifdef Rel14
...@@ -862,14 +861,11 @@ void init_eNB_proc(int inst) { ...@@ -862,14 +861,11 @@ void init_eNB_proc(int inst) {
// attr_td = &proc->attr_td; // attr_td = &proc->attr_td;
// attr_te = &proc->attr_te; // attr_te = &proc->attr_te;
#endif #endif
attr_td = &proc->attr_td;
//attr_te = &proc->attr_te[0];
//attr_te1 = &proc->attr_te[1];
//////////////////////////////////////need to modified////////////////***** //////////////////////////////////////need to modified////////////////*****
if(get_nprocs() > 2 && codingw) if(get_nprocs() > 2 && codingw)
{ {
init_te_thread(eNB); init_te_thread(eNB);
init_td_thread(eNB,attr_td); init_td_thread(eNB);
} }
//////////////////////////////////////need to modified////////////////***** //////////////////////////////////////need to modified////////////////*****
pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc ); pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc );
...@@ -941,11 +937,12 @@ void kill_eNB_proc(int inst) { ...@@ -941,11 +937,12 @@ void kill_eNB_proc(int inst) {
proc_rxtx = &proc->proc_rxtx[0]; proc_rxtx = &proc->proc_rxtx[0];
kill_td_thread(eNB);
kill_te_thread(eNB);
LOG_I(PHY, "Killing TX CC_id %d inst %d\n", CC_id, inst ); LOG_I(PHY, "Killing TX CC_id %d inst %d\n", CC_id, inst );
proc_rxtx[0].instance_cnt_rxtx = 0; // FIXME data race!
proc_rxtx[1].instance_cnt_rxtx = 0; // FIXME data race!
if (eNB->single_thread_flag==0) { if (eNB->single_thread_flag==0) {
proc_rxtx[0].instance_cnt_rxtx = 0; // FIXME data race!
proc_rxtx[1].instance_cnt_rxtx = 0; // FIXME data race!
pthread_cond_signal( &proc_rxtx[0].cond_rxtx ); pthread_cond_signal( &proc_rxtx[0].cond_rxtx );
pthread_cond_signal( &proc_rxtx[1].cond_rxtx ); pthread_cond_signal( &proc_rxtx[1].cond_rxtx );
} }
...@@ -968,14 +965,12 @@ void kill_eNB_proc(int inst) { ...@@ -968,14 +965,12 @@ void kill_eNB_proc(int inst) {
LOG_I(PHY, "Destroying UL_INFO mutex\n"); LOG_I(PHY, "Destroying UL_INFO mutex\n");
pthread_mutex_destroy(&eNB->UL_INFO_mutex); pthread_mutex_destroy(&eNB->UL_INFO_mutex);
int i; int i;
if (eNB->single_thread_flag==0) { for (i=0;i<2;i++) {
for (i=0;i<2;i++) { LOG_I(PHY, "Joining rxtx[%d] mutex/cond\n",i);
LOG_I(PHY, "Joining rxtx[%d] mutex/cond\n",i); pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status );
pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status ); LOG_I(PHY, "Destroying rxtx[%d] mutex/cond\n",i);
LOG_I(PHY, "Destroying rxtx[%d] mutex/cond\n",i); pthread_mutex_destroy( &proc_rxtx[i].mutex_rxtx );
pthread_mutex_destroy( &proc_rxtx[i].mutex_rxtx ); pthread_cond_destroy( &proc_rxtx[i].cond_rxtx );
pthread_cond_destroy( &proc_rxtx[i].cond_rxtx );
}
} }
} }
} }
......
...@@ -264,7 +264,9 @@ extern void reset_opp_meas(void); ...@@ -264,7 +264,9 @@ extern void reset_opp_meas(void);
extern void print_opp_meas(void); extern void print_opp_meas(void);
extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *); extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *);
extern void init_td_thread(PHY_VARS_eNB *, pthread_attr_t *); extern void init_td_thread(PHY_VARS_eNB *);
extern void init_te_thread(PHY_VARS_eNB *, pthread_attr_t *); extern void init_te_thread(PHY_VARS_eNB *);
extern void kill_td_thread(PHY_VARS_eNB *);
extern void kill_te_thread(PHY_VARS_eNB *);
#endif #endif
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