Fix deadlock

master
Xavier Arteaga 3 years ago committed by Xavier Arteaga
parent a5130673f6
commit d4fd4c8350

@ -420,12 +420,6 @@ int srsran_ssb_set_cfg(srsran_ssb_t* q, const srsran_ssb_cfg_t* cfg)
return SRSRAN_ERROR_INVALID_INPUTS;
}
printf("-- srate=%.2fMHz; center_freq=%.2fMHz; ssb_freq=%.2fMHz; scs=%s;\n",
cfg->srate_hz / 1e6,
cfg->center_freq_hz / 1e6,
cfg->ssb_freq_hz / 1e6,
srsran_subcarrier_spacing_to_str(cfg->scs));
// Calculate subcarrier spacing in Hz
q->scs_hz = (float)SRSRAN_SUBC_SPACING_NR(cfg->scs);
@ -1133,14 +1127,6 @@ int srsran_ssb_search(srsran_ssb_t* q, const cf_t* in, uint32_t nof_samples, srs
return SRSRAN_ERROR;
}
if (fabs(q->cfg.ssb_freq_hz - 1842.05e6) < 1e6) {
printf("-- freq=%.3f; N_id=%d; EPRE=%+.2f; RSRP=%+.2f;\n",
q->cfg.ssb_freq_hz,
N_id,
measurements.epre_dB,
measurements.rsrp_dB);
}
// Save result
res->N_id = N_id;
res->t_offset = t_offset;

@ -146,6 +146,8 @@ phy_interface_rrc_nr::phy_nr_state_t phy_nr_sa::get_state()
void phy_nr_sa::reset_nr()
{
sync.reset();
sync.cell_go_idle();
}
// This function executes one part of the procedure immediately and returns to continue in the background.
@ -157,10 +159,10 @@ bool phy_nr_sa::start_cell_search(const cell_search_args_t& req)
{
// TODO: verify arguments are valid before starting procedure
cmd_worker_cell.add_cmd([this, req]() {
logger.info("Cell Search: Going to IDLE");
sync.cell_go_idle();
cmd_worker_cell.add_cmd([this, req]() {
// Prepare cell search configuration from the request
nr::cell_search::cfg_t cfg = {};
cfg.srate_hz = req.srate_hz;

@ -185,8 +185,10 @@ sync_state::state_t sync_sa::get_state()
void sync_sa::run_state_idle()
{
#define test 1
if (radio->is_init() && test) {
if (not radio->is_init()) {
return;
}
logger.debug("Discarding samples and sending tx_end");
srsran::rf_buffer_t rf_buffer = {};
rf_buffer.set_nof_samples(slot_sz);
@ -195,10 +197,6 @@ void sync_sa::run_state_idle()
logger.error("SYNC: receiving from radio\n");
}
radio->tx_end();
} else {
logger.debug("Sleeping 1 s");
sleep(1);
}
}
void sync_sa::run_state_cell_search()
@ -221,19 +219,8 @@ void sync_sa::run_state_cell_search()
cell_search_nof_trials++;
if (cs_ret.result == cell_search::ret_t::CELL_FOUND) {
logger.error("CELL FOUND!");
rrc_interface_phy_nr::cell_search_result_t result = {};
result.cell_found = true;
result.pci = cs_ret.ssb_res.N_id;
result.pbch_msg = cs_ret.ssb_res.pbch_msg;
result.measurements = cs_ret.ssb_res.measurements;
stack->cell_search_found_cell(result);
}
// Leave CELL_SEARCH state if error or success and transition to IDLE
if (/*cs_ret.result || */ cell_search_nof_trials >= cell_search_max_trials) {
if (cs_ret.result == cell_search::ret_t::CELL_FOUND || cell_search_nof_trials >= cell_search_max_trials) {
phy_state.state_exit();
}
}

@ -38,7 +38,7 @@ public:
// Wait for tick
std::unique_lock<std::mutex> lock(pending_tti_mutex);
while (not pending_tti and running) {
pending_tti_cvar.wait(lock);
pending_tti_cvar.wait_for(lock, std::chrono::milliseconds(1));
}
// Let the tick proceed
@ -46,12 +46,13 @@ public:
pending_tti_cvar.notify_all();
}
uint32_t count = 0;
void tick()
{
// Wait for TTI to get processed
std::unique_lock<std::mutex> lock(pending_tti_mutex);
while (pending_tti) {
pending_tti_cvar.wait(lock);
while (pending_tti and running) {
pending_tti_cvar.wait_for(lock, std::chrono::milliseconds(1));
}
// Let the TTI proceed

Loading…
Cancel
Save