Commit 3720aa05 authored by Wang Tsu-Han's avatar Wang Tsu-Han

assersion condition and timedlock overflow fix

parent 7ed11406
...@@ -1099,10 +1099,15 @@ static inline int timedwait_on_condition(pthread_mutex_t *mutex,pthread_cond_t * ...@@ -1099,10 +1099,15 @@ static inline int timedwait_on_condition(pthread_mutex_t *mutex,pthread_cond_t *
// proc->instance_cnt_rxtx is -1 // proc->instance_cnt_rxtx is -1
abstime.tv_sec=now.tv_sec; abstime.tv_sec=now.tv_sec;
abstime.tv_nsec = now.tv_nsec + time_ns; abstime.tv_nsec = now.tv_nsec + time_ns;
if ((waitret = pthread_cond_timedwait(cond,mutex,&abstime))==ETIMEDOUT) break; // this unlocks mutex_rxtx while waiting and then locks it again if (abstime.tv_nsec >= 1000*1000*1000)
{
abstime.tv_nsec -= 1000*1000*1000;
abstime.tv_sec += 1;
}
if ((waitret = pthread_cond_timedwait(cond,mutex,&abstime)) == 0) break; // this unlocks mutex_rxtx while waiting and then locks it again
} }
AssertFatal((rc = pthread_mutex_unlock(mutex))==0,"[SCHED][eNB] timedwait_on_condition(): error unlocking mutex return %d for %s\n", rc, name); AssertFatal((rc = pthread_mutex_unlock(mutex)) == 0,"[SCHED][eNB] timedwait_on_condition(): error unlocking mutex return %d for %s\n", rc, name);
return(0); return(0);
} }
......
...@@ -421,6 +421,7 @@ static void *L1_thread( void *param ) { ...@@ -421,6 +421,7 @@ static void *L1_thread( void *param ) {
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB,proc->frame_tx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB,proc->frame_tx);
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_ENB,proc->frame_rx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_ENB,proc->frame_rx);
if (oai_exit) break; if (oai_exit) break;
if (eNB->CC_id==0) { if (eNB->CC_id==0) {
......
...@@ -862,7 +862,12 @@ void wakeup_slaves(RU_proc_t *proc) { ...@@ -862,7 +862,12 @@ void wakeup_slaves(RU_proc_t *proc) {
// lock the FH mutex and make sure the thread is ready // lock the FH mutex and make sure the thread is ready
clock_gettime(CLOCK_REALTIME,&wait); clock_gettime(CLOCK_REALTIME,&wait);
wait.tv_nsec += time_ns; wait.tv_nsec += time_ns;
AssertFatal((ret=pthread_mutex_timedlock(&slave_proc->mutex_FH,&wait))==ETIMEDOUT,"ERROR pthread_mutex_lock for RU %d slave %d (IC %d)\n",proc->ru->idx,slave_proc->ru->idx,slave_proc->instance_cnt_FH); if(wait.tv_nsec >= 1000*1000*1000)
{
wait.tv_nsec -= 1000*1000*1000;
wait.tv_sec += 1;
}
AssertFatal((ret=pthread_mutex_timedlock(&slave_proc->mutex_FH,&wait))==0,"ERROR pthread_mutex_lock for RU %d slave %d (IC %d)\n",proc->ru->idx,slave_proc->ru->idx,slave_proc->instance_cnt_FH);
int cnt_slave = ++slave_proc->instance_cnt_FH; int cnt_slave = ++slave_proc->instance_cnt_FH;
slave_proc->frame_rx = proc->frame_rx; slave_proc->frame_rx = proc->frame_rx;
...@@ -989,7 +994,12 @@ int wakeup_synch(RU_t *ru) { ...@@ -989,7 +994,12 @@ int wakeup_synch(RU_t *ru) {
// lock the synch mutex and make sure the thread is readif (pthread_mutex_timedlock(&ru->proc.mutex_synch,&wait) != 0) { // lock the synch mutex and make sure the thread is readif (pthread_mutex_timedlock(&ru->proc.mutex_synch,&wait) != 0) {
clock_gettime(CLOCK_REALTIME,&wait); clock_gettime(CLOCK_REALTIME,&wait);
wait.tv_nsec += time_ns; wait.tv_nsec += time_ns;
AssertFatal((ret=pthread_mutex_timedlock(&ru->proc.mutex_synch,&wait))==ETIMEDOUT,"[RU] ERROR pthread_mutex_lock for RU synch thread (IC %d)\n", ru->proc.instance_cnt_synch ); if(wait.tv_nsec >= 1000*1000*1000)
{
wait.tv_nsec -= 1000*1000*1000;
wait.tv_sec += 1;
}
AssertFatal((ret=pthread_mutex_timedlock(&ru->proc.mutex_synch,&wait)) == 0,"[RU] ERROR pthread_mutex_lock for RU synch thread (IC %d)\n", ru->proc.instance_cnt_synch );
++ru->proc.instance_cnt_synch; ++ru->proc.instance_cnt_synch;
...@@ -1189,22 +1199,18 @@ void wakeup_L1s(RU_t *ru) { ...@@ -1189,22 +1199,18 @@ void wakeup_L1s(RU_t *ru) {
} }
inline int wakeup_prach_ru(RU_t *ru) { inline int wakeup_prach_ru(RU_t *ru) {
int ret; int ret;
/*struct timespec wait; struct timespec wait;
int time_ns = 5000000L; int time_ns = 5000000L;
clock_gettime(CLOCK_REALTIME,&wait); clock_gettime(CLOCK_REALTIME,&wait);
wait.tv_nsec += time_ns; wait.tv_nsec += time_ns;
AssertFatal((ret=pthread_mutex_timedlock(&ru->proc.mutex_prach,&wait))==ETIMEDOUT,"[RU] ERROR pthread_mutex_lock for RU prach thread (IC %d)\n", ru->proc.instance_cnt_prach); if(wait.tv_nsec >= 1000*1000*1000)
*/ {
struct timespec wait; wait.tv_nsec -= 1000*1000*1000;
wait.tv_sec=0; wait.tv_sec += 1;
wait.tv_nsec=5000000L;
if (pthread_mutex_timedlock(&ru->proc.mutex_prach,&wait) !=0) {
LOG_E( PHY, "[RU] ERROR pthread_mutex_lock for RU prach thread (IC %d)\n", ru->proc.instance_cnt_prach);
exit_fun( "error locking mutex_rxtx" );
return(-1);
} }
AssertFatal((ret=pthread_mutex_timedlock(&ru->proc.mutex_prach,&wait)) == 0,"[RU] ERROR pthread_mutex_lock for RU prach thread (IC %d)\n", ru->proc.instance_cnt_prach);
if (ru->proc.instance_cnt_prach==-1) { if (ru->proc.instance_cnt_prach==-1) {
++ru->proc.instance_cnt_prach; ++ru->proc.instance_cnt_prach;
...@@ -1235,7 +1241,12 @@ inline int wakeup_prach_ru_br(RU_t *ru) { ...@@ -1235,7 +1241,12 @@ inline int wakeup_prach_ru_br(RU_t *ru) {
clock_gettime(CLOCK_REALTIME,&wait); clock_gettime(CLOCK_REALTIME,&wait);
wait.tv_nsec += time_ns; wait.tv_nsec += time_ns;
AssertFatal((ret=pthread_mutex_timedlock(&ru->proc.mutex_prach_br,&wait))==ETIMEDOUT,"[RU] ERROR pthread_mutex_lock for RU prach thread BR (IC %d)\n", ru->proc.instance_cnt_prach_br); if(wait.tv_nsec >= 1000*1000*1000)
{
wait.tv_nsec -= 1000*1000*1000;
wait.tv_sec += 1;
}
AssertFatal((ret=pthread_mutex_timedlock(&ru->proc.mutex_prach_br,&wait))==0,"[RU] ERROR pthread_mutex_lock for RU prach thread BR (IC %d)\n", ru->proc.instance_cnt_prach_br);
if (ru->proc.instance_cnt_prach_br==-1) { if (ru->proc.instance_cnt_prach_br==-1) {
......
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