From 6b506ec357b7b31a70e47db135a08f7332b15531 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Sun, 3 Oct 2021 20:05:38 +0200 Subject: [PATCH] phy_common: clear tx_hold flag before releasing the semaphore (#3342) --- lib/include/srsran/interfaces/phy_common_interface.h | 6 +++++- srsenb/src/phy/phy.cc | 1 + srsenb/src/phy/phy_common.cc | 4 ++++ srsue/src/phy/phy_common.cc | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/include/srsran/interfaces/phy_common_interface.h b/lib/include/srsran/interfaces/phy_common_interface.h index f7a2df19b..18f9e699f 100644 --- a/lib/include/srsran/interfaces/phy_common_interface.h +++ b/lib/include/srsran/interfaces/phy_common_interface.h @@ -29,6 +29,11 @@ private: bool tx_hold = false; ///< Hold threads until the signal is transmitted protected: + void reset_last_worker() + { + std::unique_lock lock(tx_mutex); + tx_hold = true; + } /** * @brief Waits for the last worker to call `last_worker()` to prevent that the current SF worker is released and * overwrites the transmit signal prior transmission @@ -36,7 +41,6 @@ protected: void wait_last_worker() { std::unique_lock lock(tx_mutex); - tx_hold = true; while (tx_hold) { tx_cvar.wait(lock); } diff --git a/srsenb/src/phy/phy.cc b/srsenb/src/phy/phy.cc index 7b77d11d1..18b174416 100644 --- a/srsenb/src/phy/phy.cc +++ b/srsenb/src/phy/phy.cc @@ -330,6 +330,7 @@ int phy::init_nr(const phy_args_t& args, const phy_cfg_t& cfg, stack_interface_p nr_workers = std::unique_ptr(new nr::worker_pool(workers_common, stack, log_sink, MAX_WORKERS)); nr::worker_pool::args_t worker_args = {}; + worker_args.nof_phy_threads = args.nof_phy_threads; worker_args.log.phy_level = args.log.phy_level; worker_args.log.phy_hex_limit = args.log.phy_hex_limit; diff --git a/srsenb/src/phy/phy_common.cc b/srsenb/src/phy/phy_common.cc index 60fca8274..1cc6c7f80 100644 --- a/srsenb/src/phy/phy_common.cc +++ b/srsenb/src/phy/phy_common.cc @@ -117,6 +117,10 @@ void phy_common::worker_end(const worker_context_t& w_ctx, const bool& tx_enable // If the current worker is not the last one, skip transmission if (not w_ctx.last) { + if (tx_enable) { + reset_last_worker(); + } + // Release semaphore and let next worker to get in semaphore.release(); diff --git a/srsue/src/phy/phy_common.cc b/srsue/src/phy/phy_common.cc index a20f17420..244e0b160 100644 --- a/srsue/src/phy/phy_common.cc +++ b/srsue/src/phy/phy_common.cc @@ -546,6 +546,10 @@ void phy_common::worker_end(const worker_context_t& w_ctx, const bool& tx_enable // If the current worker is not the last one, skip transmission if (not w_ctx.last) { + if (tx_enable) { + reset_last_worker(); + } + // Release semaphore and let next worker to get in semaphore.release();