diff --git a/srsenb/hdr/phy/nr/slot_worker.h b/srsenb/hdr/phy/nr/slot_worker.h index 776d8dadb..ab90890e5 100644 --- a/srsenb/hdr/phy/nr/slot_worker.h +++ b/srsenb/hdr/phy/nr/slot_worker.h @@ -86,6 +86,7 @@ private: srsran_gnb_ul_t gnb_ul = {}; std::vector tx_buffer; ///< Baseband transmit buffers std::vector rx_buffer; ///< Baseband receive buffers + std::mutex mutex; ///< Protect concurrent access from workers (and main process that inits the class) }; } // namespace nr diff --git a/srsenb/src/phy/nr/slot_worker.cc b/srsenb/src/phy/nr/slot_worker.cc index 814b9d33e..345a19927 100644 --- a/srsenb/src/phy/nr/slot_worker.cc +++ b/srsenb/src/phy/nr/slot_worker.cc @@ -27,6 +27,8 @@ slot_worker::slot_worker(srsran::phy_common_interface& common_, bool slot_worker::init(const args_t& args) { + std::lock_guard lock(mutex); + // Calculate subframe length sf_len = SRSRAN_SF_LEN_PRB_NR(args.nof_max_prb); @@ -104,6 +106,7 @@ slot_worker::~slot_worker() cf_t* slot_worker::get_buffer_rx(uint32_t antenna_idx) { + std::lock_guard lock(mutex); if (antenna_idx >= (uint32_t)rx_buffer.size()) { return nullptr; } @@ -113,6 +116,7 @@ cf_t* slot_worker::get_buffer_rx(uint32_t antenna_idx) cf_t* slot_worker::get_buffer_tx(uint32_t antenna_idx) { + std::lock_guard lock(mutex); if (antenna_idx >= (uint32_t)tx_buffer.size()) { return nullptr; }