Commit ed84d40f authored by mjoang's avatar mjoang

add mutex to protect ul_config_pdu against race condition.

parent 1b742fbe
......@@ -16,6 +16,7 @@
#ifndef _FAPI_NR_UE_INTERFACE_H_
#define _FAPI_NR_UE_INTERFACE_H_
#include <pthread.h>
#include "stddef.h"
#include "platform_types.h"
......@@ -349,6 +350,7 @@ typedef struct {
uint16_t slot;
uint8_t number_pdus;
fapi_nr_ul_config_request_pdu_t ul_config_list[FAPI_NR_UL_CONFIG_LIST_NUM];
pthread_mutex_t mutex_ul_config;
} fapi_nr_ul_config_request_t;
......
......@@ -153,6 +153,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
fapi_nr_ul_config_request_t *ul_config = scheduled_response->ul_config;
pthread_mutex_lock(&ul_config->mutex_ul_config);
for (i = 0; i < ul_config->number_pdus; ++i){
AssertFatal(ul_config->ul_config_list[i].pdu_type <= FAPI_NR_UL_CONFIG_TYPES,"pdu_type %d out of bounds\n",ul_config->ul_config_list[i].pdu_type);
......@@ -229,6 +230,7 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){
}
}
memset(ul_config, 0, sizeof(fapi_nr_ul_config_request_t));
pthread_mutex_unlock(&ul_config->mutex_ul_config);
}
}
return 0;
......
......@@ -40,6 +40,7 @@
#include "openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h"
#include "executables/softmodem-common.h"
#include "openair2/LAYER2/nr_pdcp/nr_pdcp.h"
#include <pthread.h>
static NR_UE_MAC_INST_t *nr_ue_mac_inst;
......@@ -74,6 +75,8 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) {
num_slots_ul++;
LOG_D(MAC, "Initializing ul_config_request. num_slots_ul = %d\n", num_slots_ul);
nr_ue_mac_inst->ul_config_request = (fapi_nr_ul_config_request_t *)calloc(num_slots_ul, sizeof(fapi_nr_ul_config_request_t));
for (int i=0; i<num_slots_ul; i++)
pthread_mutex_init(&(nr_ue_mac_inst->ul_config_request[i].mutex_ul_config), NULL);
}
}
else {
......
......@@ -30,6 +30,7 @@
#include <stdio.h>
#include <math.h>
#include <pthread.h>
/* exe */
#include <common/utils/nr/nr_common.h>
......@@ -59,11 +60,12 @@ static prach_association_pattern_t prach_assoc_pattern;
static ssb_list_info_t ssb_list;
void fill_ul_config(fapi_nr_ul_config_request_t *ul_config, frame_t frame_tx, int slot_tx, uint8_t pdu_type){
pthread_mutex_lock(&ul_config->mutex_ul_config);
ul_config->ul_config_list[ul_config->number_pdus].pdu_type = pdu_type;
ul_config->slot = slot_tx;
ul_config->sfn = frame_tx;
ul_config->number_pdus++;
pthread_mutex_unlock(&ul_config->mutex_ul_config);
LOG_D(NR_MAC, "In %s: Set config request for UL transmission in [%d.%d], number of UL PDUs: %d\n", __FUNCTION__, ul_config->sfn, ul_config->slot, ul_config->number_pdus);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment