Commit 1efbfa53 authored by Cedric Roux's avatar Cedric Roux

bugfix: fix UE realtime bug

When pushing traffic with iperf the UE was crashing.

The argument passed to pthread_mutex_timedlock is absolute time based
on the CLOCK_REALTIME timer, not relative time. That seems to be the
root cause of the bug. (That there is a timeout is another story.)

This commit uses absolute value.

Also we separate cases between IS_SOFTMODEM_BASICSIM / IS_SOFTMODEM_RFSIM
and standard realtime UE. In the 'sim' modes we don't care about
timeout and just call pthread_mutex_lock. It seems to be the idea
of the original work. If not, then to be fixed.
parent dfd5f316
......@@ -1503,6 +1503,7 @@ void *UE_thread(void *arg) {
int i;
int th_id;
static uint8_t thread_idx = 0;
int ret;
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
......@@ -1724,15 +1725,27 @@ void *UE_thread(void *arg) {
}
pickTime(gotIQs);
struct timespec tv= {0};
tv.tv_nsec=10*1000;
if( IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM)
tv.tv_sec=INT_MAX;
/* no timeout in IS_SOFTMODEM_BASICSIM or IS_SOFTMODEM_RFSIM mode */
if (IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM) {
ret = pthread_mutex_lock(&proc->mutex_rxtx);
} else {
struct timespec tv;
if (clock_gettime(CLOCK_REALTIME, &tv) != 0) {
perror("clock_gettime");
exit(1);
}
tv.tv_nsec += 10*1000;
if (tv.tv_nsec >= 1000 * 1000 * 1000) {
tv.tv_sec++;
tv.tv_nsec -= 1000 * 1000 * 1000;
}
ret = pthread_mutex_timedlock(&proc->mutex_rxtx, &tv);
}
// operate on thread sf mod 2
if (pthread_mutex_timedlock(&proc->mutex_rxtx, &tv) !=0) {
if ( errno == ETIMEDOUT) {
if (ret != 0) {
if (ret == ETIMEDOUT) {
LOG_E(PHY,"Missed real time\n");
continue;
} else {
......
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