Commit 22cd070e authored by Lionel Gauthier's avatar Lionel Gauthier

mutex !

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6101 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 1eedf2d1
...@@ -449,7 +449,7 @@ rlc_um_mac_status_indication (void *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP ...@@ -449,7 +449,7 @@ rlc_um_mac_status_indication (void *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP
status_resp.rlc_info.rlc_protocol_state = ((rlc_um_entity_t *) rlc_pP)->protocol_state; status_resp.rlc_info.rlc_protocol_state = ((rlc_um_entity_t *) rlc_pP)->protocol_state;
#ifdef DEBUG_RLC_UM_TX_STATUS #ifdef DEBUG_RLC_UM_TX_STATUS
if ((((rlc_um_entity_t *) rlc_pP)->rb_id > 0) && (status_resp.buffer_occupancy_in_bytes > 0)) { if ((((rlc_um_entity_t *) rlc_pP)->rb_id > 0) && (status_resp.buffer_occupancy_in_bytes > 0)) {
LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] MAC_STATUS_INDICATION (DATA) %d bytes -> %d bytes\n", LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] MAC_STATUS_INDICATION (DATA) %d bytes requested -> %d bytes available\n",
frameP, frameP,
(rlc_p->is_enb) ? "eNB" : "UE", (rlc_p->is_enb) ? "eNB" : "UE",
rlc_p->enb_module_id, rlc_p->enb_module_id,
...@@ -479,7 +479,7 @@ rlc_um_mac_status_indication (void *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP ...@@ -479,7 +479,7 @@ rlc_um_mac_status_indication (void *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP
} }
#endif #endif
} else { } else {
LOG_E(RLC, "[RLC] RLCp not defined!!!\n"); LOG_E(RLC, "[RLC] rlc_um_mac_status_indication RLC NULL!!!\n");
} }
return status_resp; return status_resp;
} }
...@@ -709,7 +709,9 @@ rlc_um_data_req (void *rlc_pP, frame_t frameP, mem_block_t *sdu_pP) ...@@ -709,7 +709,9 @@ rlc_um_data_req (void *rlc_pP, frame_t frameP, mem_block_t *sdu_pP)
LOG_T(RLC, "%s", message_string); LOG_T(RLC, "%s", message_string);
#endif #endif
# endif # endif
pthread_mutex_lock(&rlc_p->lock_input_sdus);
list_add_tail_eurecom(sdu_pP, &rlc_p->input_sdus); list_add_tail_eurecom(sdu_pP, &rlc_p->input_sdus);
pthread_mutex_unlock(&rlc_p->lock_input_sdus);
/*} else { /*} else {
LOG_W(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] RLC-UM_DATA_REQ input buffer full SDU garbaged\n", LOG_W(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] RLC-UM_DATA_REQ input buffer full SDU garbaged\n",
......
...@@ -240,6 +240,7 @@ rlc_um_init (rlc_um_entity_t * const rlc_pP) ...@@ -240,6 +240,7 @@ rlc_um_init (rlc_um_entity_t * const rlc_pP)
memset (rlc_pP, 0, sizeof (rlc_um_entity_t)); memset (rlc_pP, 0, sizeof (rlc_um_entity_t));
// TX SIDE // TX SIDE
list_init (&rlc_pP->pdus_to_mac_layer, NULL); list_init (&rlc_pP->pdus_to_mac_layer, NULL);
pthread_mutex_init(&rlc_pP->lock_input_sdus, NULL);
list_init (&rlc_pP->input_sdus, NULL); list_init (&rlc_pP->input_sdus, NULL);
rlc_pP->protocol_state = RLC_NULL_STATE; rlc_pP->protocol_state = RLC_NULL_STATE;
...@@ -291,6 +292,7 @@ rlc_um_cleanup (rlc_um_entity_t * const rlc_pP) ...@@ -291,6 +292,7 @@ rlc_um_cleanup (rlc_um_entity_t * const rlc_pP)
int index; int index;
// TX SIDE // TX SIDE
list_free (&rlc_pP->pdus_to_mac_layer); list_free (&rlc_pP->pdus_to_mac_layer);
pthread_mutex_destroy(&rlc_pP->lock_input_sdus);
list_free (&rlc_pP->input_sdus); list_free (&rlc_pP->input_sdus);
// RX SIDE // RX SIDE
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
# ifndef __RLC_UM_ENTITY_H__ # ifndef __RLC_UM_ENTITY_H__
# define __RLC_UM_ENTITY_H__ # define __RLC_UM_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"
...@@ -93,6 +94,8 @@ typedef struct rlc_um_entity_s { ...@@ -93,6 +94,8 @@ typedef struct rlc_um_entity_s {
// tranmission // tranmission
//----------------------------- //-----------------------------
// sdu communication; // sdu communication;
//pthread_spinlock_t lock_input_sdus;
pthread_mutex_t lock_input_sdus;
list_t input_sdus; /*!< \brief Input SDU buffer (for SDUs coming from upper layers). Should be accessed as an array. */ list_t input_sdus; /*!< \brief Input SDU buffer (for SDUs coming from upper layers). Should be accessed as an array. */
rlc_buffer_occupancy_t buffer_occupancy; /*!< \brief Number of bytes contained in input_sdus buffer.*/ rlc_buffer_occupancy_t buffer_occupancy; /*!< \brief Number of bytes contained in input_sdus buffer.*/
uint32_t nb_bytes_requested_by_mac; /*!< \brief Number of bytes requested by lower layer for next transmission. */ uint32_t nb_bytes_requested_by_mac; /*!< \brief Number of bytes requested by lower layer for next transmission. */
......
...@@ -99,6 +99,8 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP) ...@@ -99,6 +99,8 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP)
list_init (&pdus, NULL); // param string identifying the list is NULL list_init (&pdus, NULL); // param string identifying the list is NULL
pdu_mem_p = NULL; pdu_mem_p = NULL;
// not fine locking
pthread_mutex_lock(&rlc_pP->lock_input_sdus);
while ((list_get_head(&rlc_pP->input_sdus)) && (nb_bytes_to_transmit > 0)) { while ((list_get_head(&rlc_pP->input_sdus)) && (nb_bytes_to_transmit > 0)) {
#if defined(TRACE_RLC_UM_SEGMENT) #if defined(TRACE_RLC_UM_SEGMENT)
...@@ -150,6 +152,7 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP) ...@@ -150,6 +152,7 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP)
rlc_pP->ue_module_id, rlc_pP->ue_module_id,
rlc_pP->rb_id); rlc_pP->rb_id);
#endif #endif
pthread_mutex_unlock(&rlc_pP->lock_input_sdus);
return; return;
} }
#if defined(TRACE_RLC_UM_SEGMENT) #if defined(TRACE_RLC_UM_SEGMENT)
...@@ -483,6 +486,7 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP) ...@@ -483,6 +486,7 @@ rlc_um_segment_10 (rlc_um_entity_t *rlc_pP,frame_t frameP)
//nb_bytes_to_transmit = nb_bytes_to_transmit - data_pdu_size; //nb_bytes_to_transmit = nb_bytes_to_transmit - data_pdu_size;
nb_bytes_to_transmit = 0; // 1 PDU only nb_bytes_to_transmit = 0; // 1 PDU only
} }
pthread_mutex_unlock(&rlc_pP->lock_input_sdus);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
...@@ -540,6 +544,7 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP) ...@@ -540,6 +544,7 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP)
list_init (&pdus, NULL); // param string identifying the list is NULL list_init (&pdus, NULL); // param string identifying the list is NULL
pdu_mem_p = NULL; pdu_mem_p = NULL;
pthread_mutex_lock(&rlc_pP->lock_input_sdus);
while ((list_get_head(&rlc_pP->input_sdus)) && (nb_bytes_to_transmit > 0)) { while ((list_get_head(&rlc_pP->input_sdus)) && (nb_bytes_to_transmit > 0)) {
#if defined(TRACE_RLC_UM_SEGMENT) #if defined(TRACE_RLC_UM_SEGMENT)
LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 nb_bytes_to_transmit %d BO %d\n", LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 nb_bytes_to_transmit %d BO %d\n",
...@@ -590,6 +595,7 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP) ...@@ -590,6 +595,7 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP)
rlc_pP->ue_module_id, rlc_pP->ue_module_id,
rlc_pP->rb_id); rlc_pP->rb_id);
#endif #endif
pthread_mutex_unlock(&rlc_pP->lock_input_sdus);
return; return;
} }
#if defined(TRACE_RLC_UM_SEGMENT) #if defined(TRACE_RLC_UM_SEGMENT)
...@@ -919,5 +925,6 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP) ...@@ -919,5 +925,6 @@ rlc_um_segment_5 (rlc_um_entity_t *rlc_pP,frame_t frameP)
//nb_bytes_to_transmit = nb_bytes_to_transmit - data_pdu_size; //nb_bytes_to_transmit = nb_bytes_to_transmit - data_pdu_size;
nb_bytes_to_transmit = 0; // 1 PDU only nb_bytes_to_transmit = 0; // 1 PDU only
} }
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