avoid initial aberant value in semaphore test
authorLaurent MAZET <laurent.mazet@thalesgroup.com>
Fri, 17 Oct 2025 16:04:25 +0000 (18:04 +0200)
committerLaurent MAZET <laurent.mazet@thalesgroup.com>
Fri, 17 Oct 2025 16:04:25 +0000 (18:04 +0200)
semaphore.c

index 223937d694b282fd0e0415232cafc5bf14b3d712..7552ee22fc5dd2bb6dc56d37f90d8e712353fc22 100644 (file)
@@ -66,6 +66,9 @@ void *pong (__attribute__((unused)) void *arg)
         sem_wait (&sem);
         sys_timestamp (&ts2);
         deltas[i] = diff_timestamp (&ts2, &ts1);
+        if ((i == 0) && (deltas[i] > 1e9)) {
+            i--;
+        }
 
         pthread_mutex_lock (&mutex);
         usleep (TIMER);