From 7b33c48fe777292b438ef5e277abc2fc66422916 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Wed, 10 Mar 2021 21:25:11 +0100 Subject: [PATCH] Use static queue in pdu_queue --- lib/include/srslte/common/buffer_pool.h | 1 + lib/include/srslte/mac/pdu_queue.h | 10 ++++------ lib/src/mac/pdu_queue.cc | 4 +++- srsenb/src/stack/mac/ue.cc | 10 +++++----- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/include/srslte/common/buffer_pool.h b/lib/include/srslte/common/buffer_pool.h index 33f7d1be3..a2e23cb55 100644 --- a/lib/include/srslte/common/buffer_pool.h +++ b/lib/include/srslte/common/buffer_pool.h @@ -50,6 +50,7 @@ public: if (capacity_ > 0) { nof_buffers = (uint32_t)capacity_; } + used.reserve(nof_buffers); pthread_mutex_init(&mutex, nullptr); pthread_cond_init(&cv_not_empty, nullptr); for (uint32_t i = 0; i < nof_buffers; i++) { diff --git a/lib/include/srslte/mac/pdu_queue.h b/lib/include/srslte/mac/pdu_queue.h index ba89af755..9a6d40639 100644 --- a/lib/include/srslte/mac/pdu_queue.h +++ b/lib/include/srslte/mac/pdu_queue.h @@ -33,9 +33,7 @@ public: virtual void process_pdu(uint8_t* buff, uint32_t len, channel_t channel) = 0; }; - pdu_queue(srslog::basic_logger& logger, uint32_t pool_size = DEFAULT_POOL_SIZE) : - pool(pool_size), callback(NULL), logger(logger), pdu_q(pool_size) - {} + pdu_queue(srslog::basic_logger& logger) : pool(DEFAULT_POOL_SIZE), callback(NULL), logger(logger) {} void init(process_callback* callback); uint8_t* request(uint32_t len); @@ -47,7 +45,7 @@ public: void reset(); private: - const static int DEFAULT_POOL_SIZE = 64; // Number of PDU buffers in total + const static int DEFAULT_POOL_SIZE = 128; // Number of PDU buffers in total const static int MAX_PDU_LEN = 150 * 1024 / 8; // ~ 150 Mbps typedef struct { @@ -60,8 +58,8 @@ private: } pdu_t; - dyn_blocking_queue pdu_q; - buffer_pool pool; + static_blocking_queue pdu_q; + buffer_pool pool; process_callback* callback; srslog::basic_logger& logger; diff --git a/lib/src/mac/pdu_queue.cc b/lib/src/mac/pdu_queue.cc index 77b790cb2..3cb39415e 100644 --- a/lib/src/mac/pdu_queue.cc +++ b/lib/src/mac/pdu_queue.cc @@ -58,7 +58,9 @@ void pdu_queue::push(const uint8_t* ptr, uint32_t len, channel_t channel) pdu_t* pdu = (pdu_t*)ptr; pdu->len = len; pdu->channel = channel; - pdu_q.push_blocking(pdu); + if (!pdu_q.try_push(pdu)) { + logger.warning("Error pushing pdu: queue is full"); + } } else { logger.warning("Error pushing pdu: ptr is empty"); } diff --git a/srsenb/src/stack/mac/ue.cc b/srsenb/src/stack/mac/ue.cc index 99105e6e2..d04a7a969 100644 --- a/srsenb/src/stack/mac/ue.cc +++ b/srsenb/src/stack/mac/ue.cc @@ -107,11 +107,11 @@ ue::ue(uint16_t rnti_, rrc(rrc_), rlc(rlc_), phy(phy_), - logger(logger_), - mac_msg_dl(20, logger_), - mch_mac_msg_dl(10, logger_), - mac_msg_ul(20, logger_), - pdus(logger_, 128), + logger(logger), + mac_msg_dl(20, logger), + mch_mac_msg_dl(10, logger), + mac_msg_ul(20, logger), + pdus(logger), nof_rx_harq_proc(nof_rx_harq_proc_), nof_tx_harq_proc(nof_tx_harq_proc_), ta_fsm(this),