Commit 6c4ffcff authored by Lionel Gauthier's avatar Lionel Gauthier

mutex inside

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6108 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 32e7249c
...@@ -950,6 +950,7 @@ rlc_am_data_req (void *rlc_pP, frame_t frameP, mem_block_t * sdu_pP) ...@@ -950,6 +950,7 @@ rlc_am_data_req (void *rlc_pP, frame_t frameP, mem_block_t * sdu_pP)
int octet_index, index; int octet_index, index;
#endif #endif
pthread_mutex_lock(&l_rlc_p->lock_input_sdus);
if ((l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].mem_block == NULL) && if ((l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].mem_block == NULL) &&
(l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].flags.segmented == 0) && (l_rlc_p->input_sdus[l_rlc_p->next_sdu_index].flags.segmented == 0) &&
(((l_rlc_p->next_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE) != l_rlc_p->current_sdu_index)) { (((l_rlc_p->next_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE) != l_rlc_p->current_sdu_index)) {
...@@ -1076,4 +1077,5 @@ rlc_am_data_req (void *rlc_pP, frame_t frameP, mem_block_t * sdu_pP) ...@@ -1076,4 +1077,5 @@ rlc_am_data_req (void *rlc_pP, frame_t frameP, mem_block_t * sdu_pP)
l_rlc_p->next_sdu_index); l_rlc_p->next_sdu_index);
#endif #endif
} }
pthread_mutex_unlock(&l_rlc_p->lock_input_sdus);
} }
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
# ifndef __RLC_AM_ENTITY_H__ # ifndef __RLC_AM_ENTITY_H__
# define __RLC_AM_ENTITY_H__ # define __RLC_AM_ENTITY_H__
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
# include <pthread.h>
# include "platform_types.h" # include "platform_types.h"
# include "platform_constants.h" # include "platform_constants.h"
# include "list.h" # include "list.h"
...@@ -70,6 +71,8 @@ typedef struct rlc_am_entity_s { ...@@ -70,6 +71,8 @@ typedef struct rlc_am_entity_s {
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// TX BUFFERS // TX BUFFERS
//--------------------------------------------------------------------- //---------------------------------------------------------------------
//pthread_spinlock_t lock_input_sdus;
pthread_mutex_t lock_input_sdus;
rlc_am_tx_sdu_management_t *input_sdus; /*!< \brief Input SDU buffer (for SDUs coming from upper layers). */ rlc_am_tx_sdu_management_t *input_sdus; /*!< \brief Input SDU buffer (for SDUs coming from upper layers). */
signed int nb_sdu; /*!< \brief Total number of valid rlc_am_tx_sdu_management_t in input_sdus[]. */ signed int nb_sdu; /*!< \brief Total number of valid rlc_am_tx_sdu_management_t in input_sdus[]. */
signed int nb_sdu_no_segmented; /*!< \brief Total number of SDUs not segmented and partially segmented. */ signed int nb_sdu_no_segmented; /*!< \brief Total number of SDUs not segmented and partially segmented. */
......
...@@ -51,6 +51,7 @@ void rlc_am_init(rlc_am_entity_t *rlc_pP, frame_t frameP) ...@@ -51,6 +51,7 @@ void rlc_am_init(rlc_am_entity_t *rlc_pP, frame_t frameP)
list_init(&rlc_pP->segmentation_pdu_list, "SEGMENTATION PDU LIST"); list_init(&rlc_pP->segmentation_pdu_list, "SEGMENTATION PDU LIST");
//LOG_D(RLC,"RLC_AM_SDU_CONTROL_BUFFER_SIZE %d sizeof(rlc_am_tx_sdu_management_t) %d \n", RLC_AM_SDU_CONTROL_BUFFER_SIZE, sizeof(rlc_am_tx_sdu_management_t)); //LOG_D(RLC,"RLC_AM_SDU_CONTROL_BUFFER_SIZE %d sizeof(rlc_am_tx_sdu_management_t) %d \n", RLC_AM_SDU_CONTROL_BUFFER_SIZE, sizeof(rlc_am_tx_sdu_management_t));
pthread_mutex_init(&rlc_pP->lock_input_sdus, NULL);
rlc_pP->input_sdus = calloc(1, RLC_AM_SDU_CONTROL_BUFFER_SIZE*sizeof(rlc_am_tx_sdu_management_t)); rlc_pP->input_sdus = calloc(1, RLC_AM_SDU_CONTROL_BUFFER_SIZE*sizeof(rlc_am_tx_sdu_management_t));
#warning "cast the rlc retrans buffer to uint32" #warning "cast the rlc retrans buffer to uint32"
// rlc_pP->pdu_retrans_buffer = calloc(1, (uint16_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof(rlc_am_tx_data_pdu_management_t))); // rlc_pP->pdu_retrans_buffer = calloc(1, (uint16_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof(rlc_am_tx_data_pdu_management_t)));
...@@ -162,6 +163,7 @@ void rlc_am_cleanup(rlc_am_entity_t *rlc_pP) ...@@ -162,6 +163,7 @@ void rlc_am_cleanup(rlc_am_entity_t *rlc_pP)
free(rlc_pP->input_sdus); free(rlc_pP->input_sdus);
rlc_pP->input_sdus = NULL; rlc_pP->input_sdus = NULL;
} }
pthread_mutex_destroy(&rlc_pP->lock_input_sdus);
if (rlc_pP->pdu_retrans_buffer != NULL) { if (rlc_pP->pdu_retrans_buffer != NULL) {
for (i=0; i < RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE; i++) { for (i=0; i < RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE; i++) {
if (rlc_pP->pdu_retrans_buffer[i].mem_block != NULL) { if (rlc_pP->pdu_retrans_buffer[i].mem_block != NULL) {
......
...@@ -189,6 +189,7 @@ void rlc_am_segment_10 ( ...@@ -189,6 +189,7 @@ void rlc_am_segment_10 (
pdu_mem_p = NULL; pdu_mem_p = NULL;
pthread_mutex_lock(&rlc_pP->lock_input_sdus);
while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block) && (nb_bytes_to_transmit > 0) ) { while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block) && (nb_bytes_to_transmit > 0) ) {
LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] nb_bytes_to_transmit %d BO %d\n", LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] nb_bytes_to_transmit %d BO %d\n",
frameP, frameP,
...@@ -238,6 +239,7 @@ void rlc_am_segment_10 ( ...@@ -238,6 +239,7 @@ void rlc_am_segment_10 (
rlc_pP->enb_module_id, rlc_pP->enb_module_id,
rlc_pP->ue_module_id, rlc_pP->ue_module_id,
rlc_pP->rb_id); rlc_pP->rb_id);
pthread_mutex_unlock(&rlc_pP->lock_input_sdus);
return; return;
} }
LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] get new PDU %d bytes\n", LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] get new PDU %d bytes\n",
...@@ -611,4 +613,5 @@ void rlc_am_segment_10 ( ...@@ -611,4 +613,5 @@ void rlc_am_segment_10 (
list_add_tail_eurecom (copy, &rlc_pP->segmentation_pdu_list); list_add_tail_eurecom (copy, &rlc_pP->segmentation_pdu_list);
} }
pthread_mutex_unlock(&rlc_pP->lock_input_sdus);
} }
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