Fix data race in ul_harq.

master
faluco 3 years ago committed by faluco
parent d02012b588
commit 2b73beb3dd

@ -100,9 +100,9 @@ private:
srsran::ul_harq_cfg_t harq_cfg = {}; srsran::ul_harq_cfg_t harq_cfg = {};
float average_retx = 0.0; std::atomic<float> average_retx{0};
uint64_t nof_pkts = 0; uint64_t nof_pkts = 0;
ra_proc* ra_procedure = nullptr; ra_proc* ra_procedure = nullptr;
uint8_t cc_idx = 0; uint8_t cc_idx = 0;
}; };

@ -103,7 +103,7 @@ int ul_harq_entity::get_current_tbs(uint32_t pid)
float ul_harq_entity::get_average_retx() float ul_harq_entity::get_average_retx()
{ {
return average_retx; return average_retx.load(std::memory_order_relaxed);
} }
ul_harq_entity::ul_harq_process::ul_harq_process() : logger(srslog::fetch_basic_logger("MAC")) ul_harq_entity::ul_harq_process::ul_harq_process() : logger(srslog::fetch_basic_logger("MAC"))
@ -348,12 +348,15 @@ void ul_harq_entity::ul_harq_process::generate_new_tx(mac_interface_phy_lte::mac
mac_interface_phy_lte::tb_action_ul_t* action) mac_interface_phy_lte::tb_action_ul_t* action)
{ {
// Compute average number of retransmissions per packet considering previous packet // Compute average number of retransmissions per packet considering previous packet
harq_entity->average_retx = SRSRAN_VEC_CMA((float)current_tx_nb, harq_entity->average_retx, harq_entity->nof_pkts++); harq_entity->average_retx.store(SRSRAN_VEC_CMA((float)current_tx_nb,
cur_grant = grant; harq_entity->average_retx.load(std::memory_order_relaxed),
harq_feedback = false; harq_entity->nof_pkts++),
is_grant_configured = true; std::memory_order_relaxed);
current_tx_nb = 0; cur_grant = grant;
current_irv = 0; harq_feedback = false;
is_grant_configured = true;
current_tx_nb = 0;
current_irv = 0;
action->is_rar = grant.is_rar || (grant.rnti == harq_entity->rntis->get_temp_rnti()); action->is_rar = grant.is_rar || (grant.rnti == harq_entity->rntis->get_temp_rnti());

Loading…
Cancel
Save