diff --git a/openair3/NAS/UE/nas_ue_task.c b/openair3/NAS/UE/nas_ue_task.c index d548d480c78d5b30675864e931139b6aaff7dca8..d5d1f5c2093468d01698dba019cf15509800cf5a 100644 --- a/openair3/NAS/UE/nas_ue_task.c +++ b/openair3/NAS/UE/nas_ue_task.c @@ -150,6 +150,7 @@ void *nas_ue_task(void *args_p) msg_name = ITTI_MSG_NAME (msg_p); instance = ITTI_MSG_INSTANCE (msg_p); Mod_id = instance - NB_eNB_INST; + if (instance == INSTANCE_DEFAULT) abort(); nas_user_t *user = &users->item[Mod_id]; switch (ITTI_MSG_ID(msg_p)) { diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 5945431dda605a6334ba21c5678c431e49023575..0d24e9f55b320268ddd027635c3d08489c3cbbe5 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -186,7 +186,7 @@ void init_UE(int nb_inst) { } UE->rfdevice.host_type = BBU_HOST; // UE->rfdevice.type = NONE_DEV; - error_code = pthread_create(&UE->proc.pthread_ue, &UE->proc.attr_ue, UE_thread, NULL); + error_code = pthread_create(&UE->proc.pthread_ue, &UE->proc.attr_ue, UE_thread, UE); if (error_code!= 0) { LOG_D(HW,"[lte-softmodem.c] Could not allocate UE_thread, error %d\n",error_code); @@ -599,6 +599,14 @@ static void *UE_thread_synch(void *arg) } +/* this structure is used to pass both UE phy vars and + * proc to the function UE_thread_rxn_txnp4 + */ +struct rx_tx_thread_data { + PHY_VARS_UE *UE; + UE_rxtx_proc_t *proc; +}; + /*! * \brief This is the UE thread for RX subframe n and TX subframe n+4. @@ -611,9 +619,10 @@ static void *UE_thread_synch(void *arg) static void *UE_thread_rxn_txnp4(void *arg) { static int UE_thread_rxtx_retval; - UE_rxtx_proc_t *proc = (UE_rxtx_proc_t *)arg; + struct rx_tx_thread_data *rtd = arg; + UE_rxtx_proc_t *proc = rtd->proc; + PHY_VARS_UE *UE = rtd->UE; int ret; - PHY_VARS_UE *UE=PHY_vars_UE_g[0][proc->CC_id]; proc->instance_cnt_rxtx=-1; @@ -849,6 +858,7 @@ static void *UE_thread_rxn_txnp4(void *arg) } // thread finished + free(arg); return &UE_thread_rxtx_retval; } @@ -873,7 +883,7 @@ static void *UE_thread_rxn_txnp4(void *arg) void *UE_thread(void *arg) { static int UE_thread_retval; - PHY_VARS_UE *UE = PHY_vars_UE_g[0][0]; + PHY_VARS_UE *UE = arg; //PHY_vars_UE_g[0][0]; // int tx_enabled = 0; uint32_t rxs=0,txs=0; int dummy_rx[UE->frame_parms.nb_antennas_rx][UE->frame_parms.samples_per_tti] __attribute__((aligned(32))); @@ -936,7 +946,7 @@ void *UE_thread(void *arg) { #ifdef NAS_UE message_p = itti_alloc_new_message(TASK_NAS_UE, INITIALIZE_MESSAGE); - itti_send_msg_to_task (TASK_NAS_UE, INSTANCE_DEFAULT, message_p); + itti_send_msg_to_task (TASK_NAS_UE, UE->Mod_id + NB_eNB_INST, message_p); #endif while (!oai_exit) { @@ -1650,8 +1660,9 @@ void *UE_thread_old(void *arg) */ void init_UE_threads(int inst) { + struct rx_tx_thread_data *rtd; PHY_VARS_UE *UE; - + UE = PHY_vars_UE_g[inst][0]; pthread_attr_init (&UE->proc.attr_ue); @@ -1674,9 +1685,17 @@ void init_UE_threads(int inst) pthread_cond_init(&UE->proc.proc_rxtx[0].cond_rxtx,NULL); pthread_cond_init(&UE->proc.proc_rxtx[1].cond_rxtx,NULL); pthread_cond_init(&UE->proc.cond_synch,NULL); - pthread_create(&UE->proc.proc_rxtx[0].pthread_rxtx,NULL,UE_thread_rxn_txnp4,(void*)&UE->proc.proc_rxtx[0]); + rtd = calloc(1, sizeof(struct rx_tx_thread_data)); + if (rtd == NULL) abort(); + rtd->UE = PHY_vars_UE_g[inst][UE->proc.proc_rxtx[0].CC_id]; + rtd->proc = &UE->proc.proc_rxtx[0]; + pthread_create(&UE->proc.proc_rxtx[0].pthread_rxtx,NULL,UE_thread_rxn_txnp4,rtd);//(void*)&UE->proc.proc_rxtx[0]); pthread_setname_np( UE->proc.proc_rxtx[0].pthread_rxtx, "rxn_txnp4_even" ); - pthread_create(&UE->proc.proc_rxtx[1].pthread_rxtx,NULL,UE_thread_rxn_txnp4,(void*)&UE->proc.proc_rxtx[1]); + rtd = calloc(1, sizeof(struct rx_tx_thread_data)); + if (rtd == NULL) abort(); + rtd->UE = PHY_vars_UE_g[inst][UE->proc.proc_rxtx[1].CC_id]; + rtd->proc = &UE->proc.proc_rxtx[1]; + pthread_create(&UE->proc.proc_rxtx[1].pthread_rxtx,NULL,UE_thread_rxn_txnp4,rtd);//(void*)&UE->proc.proc_rxtx[1]); pthread_setname_np( UE->proc.proc_rxtx[1].pthread_rxtx, "rxn_txnp4_odd" ); pthread_create(&UE->proc.pthread_synch,NULL,UE_thread_synch,(void*)UE); pthread_setname_np( UE->proc.pthread_synch, "UE_thread_synch" );