removed uneeded sched method to set sched algorithm, and made configured flag atomic

This commit is contained in:
Francisco 2021-02-15 14:40:47 +00:00 committed by Francisco Paisana
parent 6b3cf6c597
commit 823da24a8e
6 changed files with 13 additions and 26 deletions

View File

@ -17,9 +17,9 @@
#include "sched_ue.h"
#include "srslte/common/log.h"
#include "srslte/interfaces/sched_interface.h"
#include <atomic>
#include <map>
#include <mutex>
#include <pthread.h>
#include <queue>
namespace srsenb {
@ -38,9 +38,8 @@ public:
sched();
~sched() override;
void init(rrc_interface_mac* rrc);
void init(rrc_interface_mac* rrc, const sched_args_t& sched_cfg);
int cell_cfg(const std::vector<cell_cfg_t>& cell_cfg) override;
void set_sched_cfg(sched_args_t* sched_cfg);
int reset() final;
int ue_cfg(uint16_t rnti, const ue_cfg_t& ue_cfg) final;
@ -103,7 +102,7 @@ protected:
srslte::tti_point last_tti;
std::mutex sched_mutex;
bool configured = false;
std::atomic<bool> configured;
};
} // namespace srsenb

View File

@ -58,10 +58,7 @@ bool mac::init(const mac_args_t& args_,
stack_task_queue = task_sched.make_task_queue();
scheduler.init(rrc);
// Set default scheduler configuration
scheduler.set_sched_cfg(&args.sched);
scheduler.init(rrc, args.sched);
// Init softbuffer for SI messages
common_buffers.resize(cells.size());

View File

@ -37,9 +37,10 @@ sched::sched() {}
sched::~sched() {}
void sched::init(rrc_interface_mac* rrc_)
void sched::init(rrc_interface_mac* rrc_, const sched_args_t& sched_cfg_)
{
rrc = rrc_;
rrc = rrc_;
sched_cfg = sched_cfg_;
// Initialize first carrier scheduler
carrier_schedulers.emplace_back(new carrier_sched{rrc, &ue_db, 0, &sched_results});
@ -50,7 +51,7 @@ void sched::init(rrc_interface_mac* rrc_)
int sched::reset()
{
std::lock_guard<std::mutex> lock(sched_mutex);
configured = false;
configured.store(false, std::memory_order_release);
for (std::unique_ptr<carrier_sched>& c : carrier_schedulers) {
c->reset();
}
@ -58,14 +59,7 @@ int sched::reset()
return 0;
}
void sched::set_sched_cfg(sched_interface::sched_args_t* sched_cfg_)
{
std::lock_guard<std::mutex> lock(sched_mutex);
if (sched_cfg_ != nullptr) {
sched_cfg = *sched_cfg_;
}
}
/// Called by rrc::init
int sched::cell_cfg(const std::vector<sched_interface::cell_cfg_t>& cell_cfg)
{
std::lock_guard<std::mutex> lock(sched_mutex);
@ -89,8 +83,7 @@ int sched::cell_cfg(const std::vector<sched_interface::cell_cfg_t>& cell_cfg)
carrier_schedulers[i]->carrier_cfg(sched_cell_params[i]);
}
configured = true;
configured.store(true, std::memory_order_release);
return 0;
}
@ -292,7 +285,7 @@ std::array<bool, SRSLTE_MAX_CARRIERS> sched::get_scell_activation_mask(uint16_t
// Downlink Scheduler API
int sched::dl_sched(uint32_t tti_tx_dl, uint32_t enb_cc_idx, sched_interface::dl_sched_res_t& sched_result)
{
if (!configured) {
if (not configured.load(std::memory_order_acquire)) {
return 0;
}
@ -313,7 +306,7 @@ int sched::dl_sched(uint32_t tti_tx_dl, uint32_t enb_cc_idx, sched_interface::dl
// Uplink Scheduler API
int sched::ul_sched(uint32_t tti, uint32_t enb_cc_idx, srsenb::sched_interface::ul_sched_res_t& sched_result)
{
if (!configured) {
if (not configured.load(std::memory_order_acquire)) {
return 0;
}

View File

@ -115,7 +115,6 @@ int test_scell_activation(test_scell_activation_params params)
sched_sim_event_generator generator;
// Setup scheduler
common_sched_tester tester;
tester.init(nullptr);
tester.sim_cfg(sim_args);
/* Simulation */

View File

@ -125,7 +125,7 @@ int common_sched_tester::sim_cfg(sim_sched_args args)
{
sim_args0 = std::move(args);
sched::set_sched_cfg(&sim_args0.sched_args);
sched::init(nullptr, sim_args0.sched_args);
sched_sim.reset(new sched_sim_random{this, sim_args0.cell_cfg});
sched_stats.reset(new sched_result_stats{sim_args0.cell_cfg});

View File

@ -242,7 +242,6 @@ void test_scheduler_rand(sched_sim_events sim)
sched_tester tester;
srsenb::sched my_sched;
tester.init(nullptr);
tester.sim_cfg(std::move(sim.sim_args));
tester.test_next_ttis(sim.tti_events);