Commit 55e9e9c3 authored by knopp's avatar knopp

mutexes

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7359 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 54f8a34b
......@@ -36,6 +36,7 @@
# include "intertask_interface.h"
#endif
#include "assertions.h"
#include "msc.h"
#include "hashtable.h"
#include "rlc_am.h"
#include "rlc_am_segment.h"
......@@ -47,7 +48,6 @@
#include "UTIL/LOG/log.h"
#include "UL-AM-RLC.h"
#include "DL-AM-RLC.h"
#include "msc.h"
//#define TRACE_RLC_AM_DATA_REQUEST
//#define TRACE_RLC_AM_TX_STATUS
//#define TRACE_RLC_AM_TX
......@@ -1107,7 +1107,7 @@ rlc_am_data_req (
int octet_index, index;
#endif
pthread_mutex_lock(&l_rlc_p->lock_input_sdus);
RLC_AM_MUTEX_LOCK(&l_rlc_p->lock_input_sdus, ctxt_pP, l_rlc_p);
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) &&
......@@ -1254,5 +1254,5 @@ rlc_am_data_req (
#endif
}
pthread_mutex_unlock(&l_rlc_p->lock_input_sdus);
RLC_AM_MUTEX_UNLOCK(&l_rlc_p->lock_input_sdus);
}
......@@ -96,6 +96,32 @@
(rLC_Pp->is_data_plane) ? "DRB AM" : "SRB AM",\
rLC_Pp->rb_id
#if defined(TRACE_RLC_MUTEX)
#define RLC_AM_MUTEX_LOCK(mUTEX, cTXT, rLC) \
do {\
int pmtl_rc = pthread_mutex_trylock(mUTEX);\
if (pmtl_rc != 0){\
if (pmtl_rc == EBUSY) {\
MSC_LOG_EVENT((cTXT->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,\
PROTOCOL_RLC_AM_MSC_FMT" Warning try lock %s busy",\
PROTOCOL_RLC_AM_MSC_ARGS(cTXT,rLC),\
#mUTEX);\
pthread_mutex_lock(mUTEX);\
} else {\
MSC_LOG_EVENT((cTXT->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,\
PROTOCOL_RLC_AM_MSC_FMT" Error try lock %s %d",\
PROTOCOL_RLC_AM_MSC_ARGS(cTXT,rLC),\
#mUTEX, pmtl_rc);\
}\
}\
} while (0);
#else
#define RLC_AM_MUTEX_LOCK(mUTEX, cTXT, rLC) pthread_mutex_lock(mUTEX)
#endif
#define RLC_AM_MUTEX_UNLOCK(mUTEX) pthread_mutex_unlock(mUTEX)
/*! \fn void rlc_am_release (const protocol_ctxt_t* const ctxtP, rlc_am_entity_t * const rlc_pP)
* \brief Empty function, TO DO.
* \param[in] ctxt_pP Running context.
......
......@@ -180,7 +180,7 @@ rlc_am_send_sdu (
# endif
# endif
#if !defined(ENABLE_ITTI)
pthread_mutex_unlock(&rlc_pP->lock_input_sdus);
RLC_AM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus);
#endif
MSC_LOG_TX_MESSAGE(
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,
......@@ -200,7 +200,7 @@ rlc_am_send_sdu (
rlc_pP->output_sdu_size_to_write,
rlc_pP->output_sdu_in_construction);
#if !defined(ENABLE_ITTI)
pthread_mutex_lock(&rlc_pP->lock_input_sdus);
RLC_AM_MUTEX_LOCK(&rlc_pP->lock_input_sdus, ctxt_pP, rlc_pP);
#endif
#endif
rlc_pP->output_sdu_in_construction = NULL;
......
......@@ -32,6 +32,7 @@
#include "platform_types.h"
//-----------------------------------------------------------------------------
#include "assertions.h"
#include "msc.h"
#include "rlc.h"
#include "rlc_am.h"
#include "list.h"
......@@ -271,7 +272,7 @@ rlc_am_receive_routing (
mem_block_t *tb_p = NULL;
uint8_t *first_byte_p = NULL;
sdu_size_t tb_size_in_bytes;
pthread_mutex_lock(&rlc_pP->lock_input_sdus);
RLC_AM_MUTEX_LOCK(&rlc_pP->lock_input_sdus, ctxt_pP, rlc_pP);
while ((tb_p = list_remove_head (&data_indP.data))) {
first_byte_p = ((struct mac_tb_ind *) (tb_p->data))->data_ptr;
......@@ -298,7 +299,7 @@ rlc_am_receive_routing (
rlc_pP->vr_mr);
}
} // end while
pthread_mutex_unlock(&rlc_pP->lock_input_sdus);
RLC_AM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus);
}
//-----------------------------------------------------------------------------
void
......
......@@ -36,6 +36,7 @@
//#include "rtos_header.h"
#include "platform_types.h"
//-----------------------------------------------------------------------------
#include "msc.h"
#include "list.h"
#include "rlc_am.h"
#include "LAYER2/MAC/extern.h"
......@@ -175,7 +176,7 @@ void rlc_am_segment_10 (
pdu_mem_p = NULL;
pthread_mutex_lock(&rlc_pP->lock_input_sdus);
RLC_AM_MUTEX_LOCK(&rlc_pP->lock_input_sdus, ctxt_pP, rlc_pP);
while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block) && (nb_bytes_to_transmit > 0) ) {
LOG_T(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] nb_bytes_to_transmit %d BO %d\n",
......@@ -210,7 +211,7 @@ void rlc_am_segment_10 (
if (!(pdu_mem_p = get_free_mem_block (data_pdu_size + sizeof(struct mac_tb_req)))) {
LOG_C(RLC, PROTOCOL_RLC_AM_CTXT_FMT"[SEGMENT] ERROR COULD NOT GET NEW PDU, EXIT\n",
PROTOCOL_RLC_AM_CTXT_ARGS(ctxt_pP,rlc_pP));
pthread_mutex_unlock(&rlc_pP->lock_input_sdus);
RLC_AM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus);
return;
}
......@@ -543,5 +544,5 @@ void rlc_am_segment_10 (
}
pthread_mutex_unlock(&rlc_pP->lock_input_sdus);
RLC_AM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus);
}
......@@ -37,13 +37,13 @@
# include "intertask_interface.h"
#endif
#include "assertions.h"
#include "msc.h"
#include "rlc_um.h"
#include "list.h"
#include "rlc_primitives.h"
#include "mac_primitives.h"
#include "LAYER2/MAC/extern.h"
#include "UTIL/LOG/log.h"
#include "msc.h"
#include "rlc_um_very_simple_test.h"
......@@ -779,8 +779,8 @@ rlc_um_data_req (const protocol_ctxt_t* const ctxt_pP, void *rlc_pP, mem_block_t
LOG_T(RLC, "%s", message_string);
#endif
# endif
pthread_mutex_lock(&rlc_p->lock_input_sdus);
RLC_UM_MUTEX_LOCK(&rlc_p->lock_input_sdus, ctxt_pP, rlc_p);
rlc_p->buffer_occupancy += ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_size;
list_add_tail_eurecom(sdu_pP, &rlc_p->input_sdus);
pthread_mutex_unlock(&rlc_p->lock_input_sdus);
RLC_UM_MUTEX_UNLOCK(&rlc_p->lock_input_sdus);
}
......@@ -56,6 +56,7 @@
# define public_rlc_um(x) extern x
# endif
# endif
# include <errno.h>
# include "platform_types.h"
# include "rlc_def.h"
# include "rlc_def_lte.h"
......@@ -86,6 +87,31 @@
(rLC_Pp->is_data_plane) ? "DRB UM" : "SRB UM",\
rLC_Pp->rb_id
#if defined(TRACE_RLC_MUTEX)
#define RLC_UM_MUTEX_LOCK(mUTEX, cTXT, rLC) \
do {\
int pmtl_rc = pthread_mutex_trylock(mUTEX);\
if (pmtl_rc != 0){\
if (pmtl_rc == EBUSY) {\
MSC_LOG_EVENT((cTXT->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,\
PROTOCOL_RLC_UM_MSC_FMT" Warning try lock %s busy",\
PROTOCOL_RLC_UM_MSC_ARGS(cTXT,rLC),\
#mUTEX);\
pthread_mutex_lock(mUTEX);\
} else {\
MSC_LOG_EVENT((cTXT->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,\
PROTOCOL_RLC_UM_MSC_FMT" Error try lock %s %d",\
PROTOCOL_RLC_UM_MSC_ARGS(cTXT,rLC),\
#mUTEX, pmtl_rc);\
}\
}\
} while (0);
#else
#define RLC_UM_MUTEX_LOCK(mUTEX, cTXT, rLC) pthread_mutex_lock(mUTEX)
#endif
#define RLC_UM_MUTEX_UNLOCK(mUTEX) pthread_mutex_unlock(mUTEX)
/*! \fn void rlc_um_stat_req (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t * const rlc_pP,
unsigned int* stat_tx_pdcp_sdu,
unsigned int* stat_tx_pdcp_bytes,
......
......@@ -31,6 +31,7 @@
#include "platform_types.h"
#include "assertions.h"
//-----------------------------------------------------------------------------
#include "msc.h"
#include "rlc.h"
#include "rlc_um.h"
#include "rlc_primitives.h"
......@@ -744,7 +745,7 @@ void rlc_um_check_timer_dar_time_out(
rlc_um_stop_and_reset_timer_reordering(ctxt_pP, rlc_pP);
}
pthread_mutex_unlock(&rlc_pP->lock_dar_buffer);
RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_dar_buffer);
}
}
}
......@@ -983,7 +984,7 @@ rlc_um_receive_process_dar (
free_mem_block(pdu_mem_pP);
}
pthread_mutex_lock(&rlc_pP->lock_dar_buffer);
RLC_UM_MUTEX_LOCK(&rlc_pP->lock_dar_buffer, ctxt_pP, rlc_pP);
in_window = rlc_um_in_window(ctxt_pP, rlc_pP, rlc_pP->vr_uh - rlc_pP->rx_um_window_size, sn, rlc_pP->vr_ur);
......@@ -1007,7 +1008,7 @@ rlc_um_receive_process_dar (
rlc_pP->stat_rx_data_bytes_out_of_window += tb_sizeP;
free_mem_block(pdu_mem_pP);
pdu_mem_pP = NULL;
pthread_mutex_unlock(&rlc_pP->lock_dar_buffer);
RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_dar_buffer);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_RECEIVE_PROCESS_DAR, VCD_FUNCTION_OUT);
return;
}
......@@ -1026,7 +1027,7 @@ rlc_um_receive_process_dar (
rlc_pP->stat_rx_data_bytes_duplicate += tb_sizeP;
free_mem_block(pdu_mem_pP);
pdu_mem_pP = NULL;
pthread_mutex_unlock(&rlc_pP->lock_dar_buffer);
RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_dar_buffer);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_RECEIVE_PROCESS_DAR, VCD_FUNCTION_OUT);
return;
}
......@@ -1159,6 +1160,6 @@ rlc_um_receive_process_dar (
}
}
pthread_mutex_unlock(&rlc_pP->lock_dar_buffer);
RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_dar_buffer);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RLC_UM_RECEIVE_PROCESS_DAR, VCD_FUNCTION_OUT);
}
......@@ -36,6 +36,7 @@
#include <assert.h>
#endif
#include "assertions.h"
#include "msc.h"
#include "list.h"
#include "rlc_um.h"
#include "rlc_primitives.h"
......@@ -45,7 +46,7 @@
//#define TRACE_RLC_UM_SEGMENT 1
//-----------------------------------------------------------------------------
void
rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP)
rlc_um_segment_10 (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP)
{
//-----------------------------------------------------------------------------
list_t pdus;
......@@ -89,7 +90,7 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP)
pdu_mem_p = NULL;
// not fine locking
pthread_mutex_lock(&rlc_pP->lock_input_sdus);
RLC_UM_MUTEX_LOCK(&rlc_pP->lock_input_sdus, ctxt_pP, rlc_pP);
while ((list_get_head(&rlc_pP->input_sdus)) && (nb_bytes_to_transmit > 0)) {
......@@ -129,7 +130,7 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP)
LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" ERROR COULD NOT GET NEW PDU, EXIT\n",
PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP));
#endif
pthread_mutex_unlock(&rlc_pP->lock_input_sdus);
RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus);
return;
}
......@@ -432,11 +433,11 @@ rlc_um_segment_10 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP)
nb_bytes_to_transmit = 0; // 1 PDU only
}
pthread_mutex_unlock(&rlc_pP->lock_input_sdus);
RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus);
}
//-----------------------------------------------------------------------------
void
rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP)
rlc_um_segment_5 (const protocol_ctxt_t* const ctxt_pP, rlc_um_entity_t *rlc_pP)
{
//-----------------------------------------------------------------------------
list_t pdus;
......@@ -479,7 +480,7 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP)
list_init (&pdus, NULL); // param string identifying the list is NULL
pdu_mem_p = NULL;
pthread_mutex_lock(&rlc_pP->lock_input_sdus);
RLC_UM_MUTEX_LOCK(&rlc_pP->lock_input_sdus, ctxt_pP, rlc_pP);
while ((list_get_head(&rlc_pP->input_sdus)) && (nb_bytes_to_transmit > 0)) {
#if defined(TRACE_RLC_UM_SEGMENT)
......@@ -518,7 +519,7 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP)
LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" ERROR COULD NOT GET NEW PDU, EXIT\n",
PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_pP));
#endif
pthread_mutex_unlock(&rlc_pP->lock_input_sdus);
RLC_UM_MUTEX_UNLOCK(&rlc_pP->lock_input_sdus);
return;
}
......@@ -817,6 +818,6 @@ rlc_um_segment_5 (const protocol_ctxt_t* const ctxtP, rlc_um_entity_t *rlc_pP)
nb_bytes_to_transmit = 0; // 1 PDU only
}
pthread_mutex_unlock(&rlc_pP->lock_input_sdus);
RLC_UM_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