use rnti_map_t in scheduler

master
Francisco 4 years ago committed by Francisco Paisana
parent 6b84754ede
commit b54bb35343

@ -28,9 +28,20 @@ class static_circular_map
using obj_t = std::pair<K, T>; using obj_t = std::pair<K, T>;
public: public:
using key_type = K;
using mapped_type = T;
using value_type = std::pair<K, T>;
using difference_type = std::ptrdiff_t;
class iterator class iterator
{ {
public: public:
using iterator_category = std::forward_iterator_tag;
using value_type = std::pair<K, T>;
using difference_type = std::ptrdiff_t;
using pointer = value_type*;
using reference = value_type&;
iterator() = default; iterator() = default;
iterator(static_circular_map<K, T, N>* map, size_t idx_) : ptr(map), idx(idx_) iterator(static_circular_map<K, T, N>* map, size_t idx_) : ptr(map), idx(idx_)
{ {

@ -15,11 +15,11 @@
#include "sched_grid.h" #include "sched_grid.h"
#include "sched_ue.h" #include "sched_ue.h"
#include "srsenb/hdr/common/common_enb.h"
#include "srsran/interfaces/sched_interface.h" #include "srsran/interfaces/sched_interface.h"
#include <atomic> #include <atomic>
#include <map> #include <map>
#include <mutex> #include <mutex>
#include <queue>
namespace srsenb { namespace srsenb {
@ -91,7 +91,7 @@ protected:
sched_args_t sched_cfg = {}; sched_args_t sched_cfg = {};
std::vector<sched_cell_params_t> sched_cell_params; std::vector<sched_cell_params_t> sched_cell_params;
std::map<uint16_t, std::unique_ptr<sched_ue> > ue_db; rnti_map_t<std::unique_ptr<sched_ue> > ue_db;
// independent schedulers for each carrier // independent schedulers for each carrier
std::vector<std::unique_ptr<carrier_sched> > carrier_schedulers; std::vector<std::unique_ptr<carrier_sched> > carrier_schedulers;

@ -26,10 +26,10 @@ class ra_sched;
class sched::carrier_sched class sched::carrier_sched
{ {
public: public:
explicit carrier_sched(rrc_interface_mac* rrc_, explicit carrier_sched(rrc_interface_mac* rrc_,
std::map<uint16_t, std::unique_ptr<sched_ue> >* ue_db_, sched_ue_list* ue_db_,
uint32_t enb_cc_idx_, uint32_t enb_cc_idx_,
sched_result_ringbuffer* sched_results_); sched_result_ringbuffer* sched_results_);
~carrier_sched(); ~carrier_sched();
void reset(); void reset();
void carrier_cfg(const sched_cell_params_t& sched_params_); void carrier_cfg(const sched_cell_params_t& sched_params_);
@ -51,11 +51,11 @@ private:
sf_sched* get_sf_sched(srsran::tti_point tti_rx); sf_sched* get_sf_sched(srsran::tti_point tti_rx);
// args // args
const sched_cell_params_t* cc_cfg = nullptr; const sched_cell_params_t* cc_cfg = nullptr;
srslog::basic_logger& logger; srslog::basic_logger& logger;
rrc_interface_mac* rrc = nullptr; rrc_interface_mac* rrc = nullptr;
std::map<uint16_t, std::unique_ptr<sched_ue> >* ue_db = nullptr; sched_ue_list* ue_db = nullptr;
const uint32_t enb_cc_idx; const uint32_t enb_cc_idx;
// Subframe scheduling logic // Subframe scheduling logic
srsran::circular_array<sf_sched, TTIMOD_SZ> sf_scheds; srsran::circular_array<sf_sched, TTIMOD_SZ> sf_scheds;

@ -14,15 +14,14 @@
#define SRSENB_SCHEDULER_UE_H #define SRSENB_SCHEDULER_UE_H
#include "sched_common.h" #include "sched_common.h"
#include "srsran/srslog/srslog.h"
#include <map>
#include <vector>
#include "sched_ue_ctrl/sched_lch.h" #include "sched_ue_ctrl/sched_lch.h"
#include "sched_ue_ctrl/sched_ue_cell.h" #include "sched_ue_ctrl/sched_ue_cell.h"
#include "sched_ue_ctrl/tpc.h" #include "sched_ue_ctrl/tpc.h"
#include "srsenb/hdr/common/common_enb.h"
#include "srsran/srslog/srslog.h"
#include <bitset> #include <bitset>
#include <deque> #include <map>
#include <vector>
namespace srsenb { namespace srsenb {
@ -211,7 +210,7 @@ private:
std::vector<sched_ue_cell> cells; ///< List of eNB cells that may be configured/activated/deactivated for the UE std::vector<sched_ue_cell> cells; ///< List of eNB cells that may be configured/activated/deactivated for the UE
}; };
using sched_ue_list = std::map<uint16_t, std::unique_ptr<sched_ue> >; using sched_ue_list = rnti_map_t<std::unique_ptr<sched_ue> >;
} // namespace srsenb } // namespace srsenb

@ -107,14 +107,14 @@ int sched::ue_cfg(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg)
// Add new user case // Add new user case
std::unique_ptr<sched_ue> ue{new sched_ue(rnti, sched_cell_params, ue_cfg)}; std::unique_ptr<sched_ue> ue{new sched_ue(rnti, sched_cell_params, ue_cfg)};
std::lock_guard<std::mutex> lock(sched_mutex); std::lock_guard<std::mutex> lock(sched_mutex);
ue_db.insert(std::make_pair(rnti, std::move(ue))); ue_db.insert(rnti, std::move(ue));
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;
} }
int sched::ue_rem(uint16_t rnti) int sched::ue_rem(uint16_t rnti)
{ {
std::lock_guard<std::mutex> lock(sched_mutex); std::lock_guard<std::mutex> lock(sched_mutex);
if (ue_db.count(rnti) > 0) { if (ue_db.contains(rnti)) {
ue_db.erase(rnti); ue_db.erase(rnti);
} else { } else {
Error("User rnti=0x%x not found", rnti); Error("User rnti=0x%x not found", rnti);

@ -24,11 +24,11 @@ sched_time_pf::sched_time_pf(const sched_cell_params_t& cell_params_, const sche
fairness_coeff = std::stof(sched_args.sched_policy_args); fairness_coeff = std::stof(sched_args.sched_policy_args);
} }
std::vector<ue_ctxt *> dl_storage; std::vector<ue_ctxt*> dl_storage;
dl_storage.reserve(SRSENB_MAX_UES); dl_storage.reserve(SRSENB_MAX_UES);
dl_queue = ue_dl_queue_t(ue_dl_prio_compare{}, std::move(dl_storage)); dl_queue = ue_dl_queue_t(ue_dl_prio_compare{}, std::move(dl_storage));
std::vector<ue_ctxt *> ul_storage; std::vector<ue_ctxt*> ul_storage;
ul_storage.reserve(SRSENB_MAX_UES); ul_storage.reserve(SRSENB_MAX_UES);
ul_queue = ue_ul_queue_t(ue_ul_prio_compare{}, std::move(ul_storage)); ul_queue = ue_ul_queue_t(ue_ul_prio_compare{}, std::move(ul_storage));
} }
@ -38,7 +38,7 @@ void sched_time_pf::new_tti(sched_ue_list& ue_db, sf_sched* tti_sched)
current_tti_rx = tti_point{tti_sched->get_tti_rx()}; current_tti_rx = tti_point{tti_sched->get_tti_rx()};
// remove deleted users from history // remove deleted users from history
for (auto it = ue_history_db.begin(); it != ue_history_db.end();) { for (auto it = ue_history_db.begin(); it != ue_history_db.end();) {
if (not ue_db.count(it->first)) { if (not ue_db.contains(it->first)) {
it = ue_history_db.erase(it); it = ue_history_db.erase(it);
} else { } else {
++it; ++it;

Loading…
Cancel
Save