From 1fd9d4300c019dac86a3aaddd6439c04cae86a39 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Wed, 14 Jul 2021 11:18:46 +0200 Subject: [PATCH] Move pdu buffer mutex in mac::ue to each carrier buffer map --- srsenb/hdr/stack/mac/ue.h | 2 +- srsenb/src/stack/mac/ue.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/srsenb/hdr/stack/mac/ue.h b/srsenb/hdr/stack/mac/ue.h index 3718771ad..8855d9a1b 100644 --- a/srsenb/hdr/stack/mac/ue.h +++ b/srsenb/hdr/stack/mac/ue.h @@ -81,6 +81,7 @@ public: private: srslog::basic_logger* logger; + std::mutex mutex; srsran::static_circular_map pdu_map; }; @@ -215,7 +216,6 @@ private: // Mutexes std::mutex mutex; - std::mutex rx_buffers_mutex; }; } // namespace srsenb diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index cae9939f2..791b08725 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -71,6 +71,7 @@ cc_used_buffers_map::~cc_used_buffers_map() srsran::unique_byte_buffer_t cc_used_buffers_map::release_pdu(tti_point tti) { + std::unique_lock lock(mutex); if (not has_tti(tti)) { return nullptr; } @@ -85,6 +86,7 @@ srsran::unique_byte_buffer_t cc_used_buffers_map::release_pdu(tti_point tti) uint8_t* cc_used_buffers_map::request_pdu(tti_point tti, uint32_t len) { + std::unique_lock lock(mutex); if (not pdu_map.has_space(tti.to_uint())) { logger->error("UE buffers: could not allocate buffer for tti=%d", tti.to_uint()); return nullptr; @@ -105,6 +107,7 @@ uint8_t* cc_used_buffers_map::request_pdu(tti_point tti, uint32_t len) void cc_used_buffers_map::clear_old_pdus(tti_point current_tti) { + std::unique_lock lock(mutex); static const uint32_t old_tti_threshold = SRSRAN_FDD_NOF_HARQ + 4; tti_point max_tti{current_tti - old_tti_threshold}; @@ -253,13 +256,11 @@ srsran_softbuffer_tx_t* ue::get_tx_softbuffer(uint32_t enb_cc_idx, uint32_t harq uint8_t* ue::request_buffer(uint32_t tti, uint32_t enb_cc_idx, uint32_t len) { srsran_assert(len > 0, "UE buffers: Requesting buffer for zero bytes"); - std::unique_lock lock(rx_buffers_mutex); return cc_buffers[enb_cc_idx].get_rx_used_buffers().request_pdu(tti_point(tti), len); } void ue::clear_old_buffers(uint32_t tti) { - std::unique_lock lock(rx_buffers_mutex); // remove old buffers for (auto& cc : cc_buffers) { cc.get_rx_used_buffers().clear_old_pdus(tti_point{tti}); @@ -389,7 +390,6 @@ void ue::process_pdu(srsran::unique_byte_buffer_t pdu, uint32_t ue_cc_idx, uint3 srsran::unique_byte_buffer_t ue::release_pdu(uint32_t tti, uint32_t enb_cc_idx) { - std::lock_guard lock(rx_buffers_mutex); return cc_buffers[enb_cc_idx].get_rx_used_buffers().release_pdu(tti_point(tti)); }