optimization - only allow some multiqueue queues to notify the multiqueue consumer of the arrival of tasks

master
Francisco 4 years ago committed by Ismael Gomez
parent 8414b2c2c9
commit f705735093

@ -66,6 +66,11 @@ class multiqueue_handler
return active_;
}
void set_notify_mode()
{
std::unique_lock<std::mutex> lock(q_mutex);
notify_mode = true;
}
void set_active(bool val)
{
std::unique_lock<std::mutex> lock(q_mutex);
@ -152,7 +157,7 @@ class multiqueue_handler
}
}
buffer.push(std::forward<T>(*o));
if (consumer_notify_needed) {
if (consumer_notify_needed and notify_mode) {
// Note: The consumer thread only needs to be notified and awaken when queues transition from empty to non-empty
// To ensure that the consumer noticed that the queue was empty before a push, we store the last
// try_pop() return in a member variable.
@ -170,6 +175,7 @@ class multiqueue_handler
std::condition_variable cv_full, cv_exit;
bool active_ = true;
bool consumer_notify_needed = true;
bool notify_mode = false;
int nof_waiting = 0;
};
@ -192,6 +198,7 @@ public:
impl = nullptr;
}
}
void set_notify_mode() { impl->set_notify_mode(); }
size_t size() { return impl->size(); }
size_t capacity() { return impl->capacity(); }

@ -122,7 +122,7 @@ private:
// task handling
srsran::task_scheduler task_sched;
srsran::task_queue_handle enb_task_queue, sync_task_queue;
srsran::task_queue_handle enb_task_queue, sync_task_queue, metrics_task_queue;
srsenb::mac mac;
srsenb::rlc rlc;

@ -42,6 +42,8 @@ enb_stack_lte::enb_stack_lte(srslog::sink& log_sink) :
{
get_background_workers().set_nof_workers(2);
enb_task_queue = task_sched.make_task_queue();
enb_task_queue.set_notify_mode();
metrics_task_queue = task_sched.make_task_queue();
// sync_queue is added in init()
}
@ -96,7 +98,7 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
// Set up pcap and trace
if (args.mac_pcap.enable) {
mac_pcap.open(args.mac_pcap.filename.c_str());
mac_pcap.open(args.mac_pcap.filename);
mac.start_pcap(&mac_pcap);
}
@ -115,6 +117,7 @@ int enb_stack_lte::init(const stack_args_t& args_, const rrc_cfg_t& rrc_cfg_)
// add sync queue
sync_task_queue = task_sched.make_task_queue(args.sync_queue_size);
sync_task_queue.set_notify_mode();
// Init all layers
if (!mac.init(args.mac, rrc_cfg.cell_list, phy, &rlc, &rrc)) {
@ -202,7 +205,7 @@ void enb_stack_lte::stop_impl()
bool enb_stack_lte::get_metrics(stack_metrics_t* metrics)
{
// use stack thread to query metrics
auto ret = enb_task_queue.try_push([this]() {
auto ret = metrics_task_queue.try_push([this]() {
stack_metrics_t metrics{};
mac.get_metrics(metrics.mac);
if (not metrics.mac.ues.empty()) {

@ -26,10 +26,12 @@ gnb_stack_nr::gnb_stack_nr() : task_sched{512, 128}, thread("gNB"), rlc_logger(s
m_gw.reset(new srsue::gw());
// m_gtpu.reset(new srsenb::gtpu());
ue_task_queue = task_sched.make_task_queue();
ue_task_queue = task_sched.make_task_queue();
ue_task_queue.set_notify_mode();
sync_task_queue = task_sched.make_task_queue();
gw_task_queue = task_sched.make_task_queue();
mac_task_queue = task_sched.make_task_queue();
sync_task_queue.set_notify_mode();
gw_task_queue = task_sched.make_task_queue();
mac_task_queue = task_sched.make_task_queue();
}
gnb_stack_nr::~gnb_stack_nr()

@ -52,7 +52,8 @@ ue_stack_lte::ue_stack_lte() :
tti_tprof("tti_tprof", "STCK", TTI_STAT_PERIOD)
{
get_background_workers().set_nof_workers(2);
ue_task_queue = task_sched.make_task_queue();
ue_task_queue = task_sched.make_task_queue();
ue_task_queue.set_notify_mode();
gw_queue_id = task_sched.make_task_queue();
cfg_task_queue = task_sched.make_task_queue();
// sync_queue is added in init()
@ -199,6 +200,7 @@ int ue_stack_lte::init(const stack_args_t& args_)
// add sync queue
sync_task_queue = task_sched.make_task_queue(args.sync_queue_size);
sync_task_queue.set_notify_mode();
mac.init(phy, &rlc, &rrc);
rlc.init(&pdcp, &rrc, &rrc_nr, task_sched.get_timer_handler(), 0 /* RB_ID_SRB0 */);

@ -33,9 +33,11 @@ ue_stack_nr::ue_stack_nr() :
// setup logging for pool, RLC and PDCP
byte_buffer_pool::get_instance()->enable_logger(true);
ue_task_queue = task_sched.make_task_queue();
ue_task_queue = task_sched.make_task_queue();
ue_task_queue.set_notify_mode();
sync_task_queue = task_sched.make_task_queue();
gw_task_queue = task_sched.make_task_queue();
sync_task_queue.set_notify_mode();
gw_task_queue = task_sched.make_task_queue();
}
ue_stack_nr::~ue_stack_nr()

Loading…
Cancel
Save