phy_common: clear tx_hold flag before releasing the semaphore (#3342)

This commit is contained in:
Ismael Gomez 2021-10-03 20:05:38 +02:00 committed by GitHub
parent f8d55a6fd3
commit 6b506ec357
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 1 deletions

View File

@ -29,6 +29,11 @@ private:
bool tx_hold = false; ///< Hold threads until the signal is transmitted
protected:
void reset_last_worker()
{
std::unique_lock<std::mutex> lock(tx_mutex);
tx_hold = true;
}
/**
* @brief Waits for the last worker to call `last_worker()` to prevent that the current SF worker is released and
* overwrites the transmit signal prior transmission
@ -36,7 +41,6 @@ protected:
void wait_last_worker()
{
std::unique_lock<std::mutex> lock(tx_mutex);
tx_hold = true;
while (tx_hold) {
tx_cvar.wait(lock);
}

View File

@ -330,6 +330,7 @@ int phy::init_nr(const phy_args_t& args, const phy_cfg_t& cfg, stack_interface_p
nr_workers = std::unique_ptr<nr::worker_pool>(new nr::worker_pool(workers_common, stack, log_sink, MAX_WORKERS));
nr::worker_pool::args_t worker_args = {};
worker_args.nof_phy_threads = args.nof_phy_threads;
worker_args.log.phy_level = args.log.phy_level;
worker_args.log.phy_hex_limit = args.log.phy_hex_limit;

View File

@ -117,6 +117,10 @@ void phy_common::worker_end(const worker_context_t& w_ctx, const bool& tx_enable
// If the current worker is not the last one, skip transmission
if (not w_ctx.last) {
if (tx_enable) {
reset_last_worker();
}
// Release semaphore and let next worker to get in
semaphore.release();

View File

@ -546,6 +546,10 @@ void phy_common::worker_end(const worker_context_t& w_ctx, const bool& tx_enable
// If the current worker is not the last one, skip transmission
if (not w_ctx.last) {
if (tx_enable) {
reset_last_worker();
}
// Release semaphore and let next worker to get in
semaphore.release();