From 2adb1c0723df0868bf9010bdf72d1da8c37056c7 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Fri, 30 Jul 2021 12:11:47 +0200 Subject: [PATCH] sched_nr_worker: make cond var to sync workers an integer the boolean isn't enough for more than 2 PHY workers, replace by int --- srsenb/hdr/stack/mac/nr/sched_nr_worker.h | 2 +- srsenb/src/stack/mac/nr/sched_nr_worker.cc | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_worker.h b/srsenb/hdr/stack/mac/nr/sched_nr_worker.h index 0818cca28..c9b14a35e 100644 --- a/srsenb/hdr/stack/mac/nr/sched_nr_worker.h +++ b/srsenb/hdr/stack/mac/nr/sched_nr_worker.h @@ -120,7 +120,7 @@ private: std::vector > slot_worker_ctxts; struct cc_context { std::condition_variable cvar; - bool waiting = false; + int waiting = 0; slot_cc_worker worker; cc_context(serv_cell_manager& sched) : worker(sched) {} diff --git a/srsenb/src/stack/mac/nr/sched_nr_worker.cc b/srsenb/src/stack/mac/nr/sched_nr_worker.cc index dbb99ff91..0b783d2b6 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_worker.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_worker.cc @@ -237,9 +237,9 @@ void sched_worker_manager::run_slot(slot_point slot_tx, uint32_t cc, dl_sched_t& std::unique_lock lock(slot_mutex); while (current_slot.valid() and current_slot != slot_tx) { // Wait for previous slot to finish - cc_worker_list[cc]->waiting = true; + cc_worker_list[cc]->waiting++; cc_worker_list[cc]->cvar.wait(lock); - cc_worker_list[cc]->waiting = false; + cc_worker_list[cc]->waiting--; } if (not current_slot.valid()) { /* First Worker to start slot */ @@ -261,7 +261,7 @@ void sched_worker_manager::run_slot(slot_point slot_tx, uint32_t cc, dl_sched_t& current_slot = slot_tx; worker_count.store(static_cast(cc_worker_list.size()), std::memory_order_relaxed); for (auto& w : cc_worker_list) { - if (w->waiting) { + if (w->waiting > 0) { waiting_cvars.push_back(&w->cvar); } } @@ -301,7 +301,7 @@ void sched_worker_manager::run_slot(slot_point slot_tx, uint32_t cc, dl_sched_t& // All the workers of the same slot have finished. Synchronize scheduling decisions with UEs state for (auto& c : cc_worker_list) { c->worker.finish(); - if (c->waiting) { + if (c->waiting > 0) { waiting_cvars.push_back(&c->cvar); } }