prach: protect configuration and state getters with mutex

purely TSAN with unit-test based approach that protects
the state getters and configuration routines with a mutex
master
Andre Puschmann 4 years ago
parent d2ec3ca5e1
commit b0a2f31478

@ -18,6 +18,7 @@
#include "srsran/srslog/srslog.h"
#include "srsran/srsran.h"
#include <bitset>
#include <mutex>
namespace srsue {
@ -70,6 +71,7 @@ private:
bool mem_initiated = false;
bool cell_initiated = false;
std::bitset<max_fs * max_preambles> buffer_bitmask;
mutable std::mutex mutex;
};
} // namespace srsue

@ -83,6 +83,8 @@ void prach::stop()
bool prach::set_cell(srsran_cell_t cell_, srsran_prach_cfg_t prach_cfg)
{
std::lock_guard<std::mutex> lock(mutex);
if (!mem_initiated) {
ERROR("PRACH: Error must call init() first");
return false;
@ -147,6 +149,7 @@ bool prach::generate_buffer(uint32_t f_idx)
bool prach::prepare_to_send(uint32_t preamble_idx_, int allowed_subframe_, float target_power_dbm_)
{
std::lock_guard<std::mutex> lock(mutex);
if (preamble_idx_ >= max_preambles) {
Error("PRACH: Invalid preamble %d", preamble_idx_);
return false;
@ -162,7 +165,11 @@ bool prach::prepare_to_send(uint32_t preamble_idx_, int allowed_subframe_, float
bool prach::is_pending() const
{
return cell_initiated && preamble_idx >= 0 && unsigned(preamble_idx) < max_preambles;
std::unique_lock<std::mutex> lock(mutex, std::try_to_lock);
if (lock.owns_lock()) {
return cell_initiated && preamble_idx >= 0 && unsigned(preamble_idx) < max_preambles;
}
return false;
}
bool prach::is_ready_to_send(uint32_t current_tti_, uint32_t current_pci)

Loading…
Cancel
Save