Make kpi variables atomic
Mutex for phy scope: Repeating this change again. My earlier change in commit 06ef311975 was erased by someone during merge of QT scope.
This commit is contained in:
+3
-1
@@ -2016,7 +2016,9 @@ add_boolean_option(ENABLE_NRQTSCOPE OFF "Build the Qt-Scope" OFF)
|
|||||||
if (ENABLE_NRQTSCOPE)
|
if (ENABLE_NRQTSCOPE)
|
||||||
find_package(Qt5 REQUIRED COMPONENTS Widgets Charts)
|
find_package(Qt5 REQUIRED COMPONENTS Widgets Charts)
|
||||||
message ("Qt5 Widgets and Charts found for nrqtscope")
|
message ("Qt5 Widgets and Charts found for nrqtscope")
|
||||||
set(QTSCOPE_SOURCE_NR ${OPENAIR1_DIR}/PHY/TOOLS/nr_phy_qt_scope.cpp)
|
set(QTSCOPE_SOURCE_NR
|
||||||
|
${OPENAIR1_DIR}/PHY/TOOLS/nr_phy_qt_scope.cpp
|
||||||
|
${OPENAIR1_DIR}/PHY/TOOLS/phy_scope_interface.c)
|
||||||
# Creates rules for calling the Meta-Object Compiler (moc) on the given source files
|
# Creates rules for calling the Meta-Object Compiler (moc) on the given source files
|
||||||
qt5_wrap_cpp(QTSCOPE_SOURCE_NR ${OPENAIR1_DIR}/PHY/TOOLS/nr_phy_qt_scope.h)
|
qt5_wrap_cpp(QTSCOPE_SOURCE_NR ${OPENAIR1_DIR}/PHY/TOOLS/nr_phy_qt_scope.h)
|
||||||
add_library(nrqtscope MODULE ${QTSCOPE_SOURCE_NR})
|
add_library(nrqtscope MODULE ${QTSCOPE_SOURCE_NR})
|
||||||
|
|||||||
@@ -1147,6 +1147,7 @@ void nrUEinitQtScope(PHY_VARS_NR_UE *ue)
|
|||||||
|
|
||||||
scope->liveData = calloc(sizeof(scopeGraphData_t *), UEdataTypeNumberOfItems);
|
scope->liveData = calloc(sizeof(scopeGraphData_t *), UEdataTypeNumberOfItems);
|
||||||
scope->copyData = UEcopyData;
|
scope->copyData = UEcopyData;
|
||||||
|
UEcopyDataMutexInit();
|
||||||
|
|
||||||
ue->scopeData = scope;
|
ue->scopeData = scope;
|
||||||
|
|
||||||
|
|||||||
@@ -1137,8 +1137,6 @@ static void *nrUEscopeThread(void *arg) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pthread_mutex_t UEcopyDataMutex;
|
|
||||||
|
|
||||||
STATICFORXSCOPE void nrUEinitScope(PHY_VARS_NR_UE *ue)
|
STATICFORXSCOPE void nrUEinitScope(PHY_VARS_NR_UE *ue)
|
||||||
{
|
{
|
||||||
AssertFatal(ue->scopeData=malloc(sizeof(scopeData_t)),"");
|
AssertFatal(ue->scopeData=malloc(sizeof(scopeData_t)),"");
|
||||||
@@ -1148,8 +1146,8 @@ STATICFORXSCOPE void nrUEinitScope(PHY_VARS_NR_UE *ue)
|
|||||||
#ifndef WEBSRVSCOPE
|
#ifndef WEBSRVSCOPE
|
||||||
pthread_t forms_thread;
|
pthread_t forms_thread;
|
||||||
threadCreate(&forms_thread, nrUEscopeThread, ue, "scope", -1, OAI_PRIORITY_RT_LOW);
|
threadCreate(&forms_thread, nrUEscopeThread, ue, "scope", -1, OAI_PRIORITY_RT_LOW);
|
||||||
|
UEcopyDataMutexInit();
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_init(&UEcopyDataMutex, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nrscope_autoinit(void *dataptr) {
|
void nrscope_autoinit(void *dataptr) {
|
||||||
|
|||||||
@@ -35,9 +35,16 @@
|
|||||||
#include "phy_scope_interface.h"
|
#include "phy_scope_interface.h"
|
||||||
|
|
||||||
#define SOFTSCOPE_ENDFUNC_IDX 0
|
#define SOFTSCOPE_ENDFUNC_IDX 0
|
||||||
|
#define THREAD_MEM 4
|
||||||
|
|
||||||
static loader_shlibfunc_t scope_fdesc[]= {{"end_forms",NULL}};
|
static loader_shlibfunc_t scope_fdesc[]= {{"end_forms",NULL}};
|
||||||
|
|
||||||
|
pthread_mutex_t UEcopyDataMutex;
|
||||||
|
|
||||||
|
int UEcopyDataMutexInit(void) {
|
||||||
|
return pthread_mutex_init(&UEcopyDataMutex, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
int load_softscope(char *exectype, void *initarg) {
|
int load_softscope(char *exectype, void *initarg) {
|
||||||
char libname[64];
|
char libname[64];
|
||||||
sprintf(libname,"%.10sscope",exectype);
|
sprintf(libname,"%.10sscope",exectype);
|
||||||
@@ -56,16 +63,19 @@ int end_forms(void) {
|
|||||||
void UEcopyData(PHY_VARS_NR_UE *ue, enum UEdataType type, void *dataIn, int elementSz, int colSz, int lineSz) {
|
void UEcopyData(PHY_VARS_NR_UE *ue, enum UEdataType type, void *dataIn, int elementSz, int colSz, int lineSz) {
|
||||||
// Local static copy of the scope data bufs
|
// Local static copy of the scope data bufs
|
||||||
// The active data buf is alterned to avoid interference between the Scope thread (display) and the Rx thread (data input)
|
// The active data buf is alterned to avoid interference between the Scope thread (display) and the Rx thread (data input)
|
||||||
// Index of "2" could be set to the number of Rx threads + 1
|
// Index of THREAD_MEM could be set to the number of Rx threads + 1. Rx slots could run asynchronous to each other.
|
||||||
static scopeGraphData_t *copyDataBufs[UEdataTypeNumberOfItems][2] = {0};
|
// THREAD_MEM = 4 slot process running in parallel is an assumption. THREAD_MEM can be increased if scope appears inconsistent.
|
||||||
|
static scopeGraphData_t *copyDataBufs[UEdataTypeNumberOfItems][THREAD_MEM] = {0};
|
||||||
static int copyDataBufsIdx[UEdataTypeNumberOfItems] = {0};
|
static int copyDataBufsIdx[UEdataTypeNumberOfItems] = {0};
|
||||||
|
|
||||||
scopeData_t *tmp = (scopeData_t *)ue->scopeData;
|
scopeData_t *tmp = (scopeData_t *)ue->scopeData;
|
||||||
|
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
// Begin of critical zone between UE Rx threads that might copy new data at the same time: might require a mutex
|
// Begin of critical zone between UE Rx threads that might copy new data at the same time:
|
||||||
int newCopyDataIdx = (copyDataBufsIdx[type]==0)?1:0;
|
pthread_mutex_lock(&UEcopyDataMutex);
|
||||||
|
int newCopyDataIdx = (copyDataBufsIdx[type]<(THREAD_MEM-1))?copyDataBufsIdx[type]+1:0;
|
||||||
copyDataBufsIdx[type] = newCopyDataIdx;
|
copyDataBufsIdx[type] = newCopyDataIdx;
|
||||||
|
pthread_mutex_unlock(&UEcopyDataMutex);
|
||||||
// End of critical zone between UE Rx threads
|
// End of critical zone between UE Rx threads
|
||||||
|
|
||||||
// New data will be copied in a different buffer than the live one
|
// New data will be copied in a different buffer than the live one
|
||||||
|
|||||||
@@ -31,15 +31,21 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef __PHY_SCOPE_INTERFACE_H__
|
#ifndef __PHY_SCOPE_INTERFACE_H__
|
||||||
#define __PHY_SCOPE_INTERFACE_H__
|
#define __PHY_SCOPE_INTERFACE_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#include <atomic>
|
||||||
|
#define _Atomic(X) std::atomic< X >
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <openair1/PHY/defs_gNB.h>
|
#include <openair1/PHY/defs_gNB.h>
|
||||||
#include <openair1/PHY/defs_nr_UE.h>
|
#include <openair1/PHY/defs_nr_UE.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t nb_total;
|
_Atomic(uint32_t) nb_total;
|
||||||
uint32_t nb_nack;
|
_Atomic(uint32_t) nb_nack;
|
||||||
uint32_t blockSize; // block size, to be used for throughput calculation
|
_Atomic(uint32_t) blockSize; // block size, to be used for throughput calculation
|
||||||
uint16_t nofRBs;
|
_Atomic(uint16_t) nofRBs;
|
||||||
uint8_t dl_mcs;
|
_Atomic(uint8_t ) dl_mcs;
|
||||||
} extended_kpi_ue;
|
} extended_kpi_ue;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -80,6 +86,7 @@ typedef struct {
|
|||||||
|
|
||||||
int load_softscope(char *exectype, void *initarg);
|
int load_softscope(char *exectype, void *initarg);
|
||||||
int end_forms(void) ;
|
int end_forms(void) ;
|
||||||
|
int UEcopyDataMutexInit(void);
|
||||||
void UEcopyData(PHY_VARS_NR_UE *ue, enum UEdataType type, void *dataIn, int elementSz, int colSz, int lineSz);
|
void UEcopyData(PHY_VARS_NR_UE *ue, enum UEdataType type, void *dataIn, int elementSz, int colSz, int lineSz);
|
||||||
|
|
||||||
#define UEscopeCopy(ue, type, ...) if(ue->scopeData) ((scopeData_t*)ue->scopeData)->copyData(ue, type, ##__VA_ARGS__);
|
#define UEscopeCopy(ue, type, ...) if(ue->scopeData) ((scopeData_t*)ue->scopeData)->copyData(ue, type, ##__VA_ARGS__);
|
||||||
|
|||||||
@@ -32,6 +32,10 @@
|
|||||||
#ifndef __PHY_DEFS_NR_UE__H__
|
#ifndef __PHY_DEFS_NR_UE__H__
|
||||||
#define __PHY_DEFS_NR_UE__H__
|
#define __PHY_DEFS_NR_UE__H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#include <atomic>
|
||||||
|
#define _Atomic(X) std::atomic< X >
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "defs_nr_common.h"
|
#include "defs_nr_common.h"
|
||||||
#include "CODING/nrPolar_tools/nr_polar_pbch_defs.h"
|
#include "CODING/nrPolar_tools/nr_polar_pbch_defs.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user