for (int i = 0; i < nb_measurements; i++) {
+ pthread_mutex_lock (&mutex);
+ usleep (TIMER);
+ pthread_mutex_unlock (&mutex);
+
char buffer[MAXBUF] = { 0 };
if (mq_receive (mq_in, buffer, sizeof (buffer), NULL) == -1) {
fprintf (stderr, "pong error: mq_receive (%d)\n", i);
sys_timestamp (&ts2);
deltas[i] = diff_timestamp (&ts2, &ts1);
-
- pthread_mutex_lock (&mutex);
- usleep (TIMER);
- pthread_mutex_unlock (&mutex);
}
mq_close (mq_in);
for (int i = 0; i < nb_measurements; i++) {
+ pthread_mutex_lock (&mutex);
+ usleep (TIMER);
+ pthread_mutex_unlock (&mutex);
+
char buffer[MAXBUF] = { 0 };
if (read (fdin, buffer, sizeof(buffer)) == -1) {
fprintf (stderr, "pong error: read (%d)\n", i);
sys_timestamp (&ts2);
deltas[i] = diff_timestamp (&ts2, &ts1);
-
- pthread_mutex_lock (&mutex);
- usleep (TIMER);
- pthread_mutex_unlock (&mutex);
}
close (fdin);
for (int i = 0; i < nb_measurements; i++) {
- 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);
pthread_mutex_unlock (&mutex);
+
+ sem_wait (&sem);
+ sys_timestamp (&ts2);
+ deltas[i] = diff_timestamp (&ts2, &ts1);
}
pthread_exit (NULL);
for (int i = 0; i < nb_measurements; i++) {
+ pthread_mutex_lock (&mutex);
+ usleep (TIMER);
+ pthread_mutex_unlock (&mutex);
+
char buffer[MAXBUF] = { 0 };
struct sockaddr_in src = { 0 };
socklen_t alen = sizeof (src);
}
sys_timestamp (&ts2);
deltas[i] = diff_timestamp (&ts2, &ts1);
-
- pthread_mutex_lock (&mutex);
- usleep (TIMER);
- pthread_mutex_unlock (&mutex);
}
close (sock);