+static void *gtod_thread_main(void *data)
+{
+ fio_mutex_up(startup_mutex);
+
+ /*
+ * As long as we have jobs around, update the clock. It would be nice
+ * to have some way of NOT hammering that CPU with gettimeofday(),
+ * but I'm not sure what to use outside of a simple CPU nop to relax
+ * it - we don't want to lose precision.
+ */
+ while (threads) {
+ fio_gtod_update();
+ nop;
+ }
+
+ return NULL;
+}
+
+static int fio_start_gtod_thread(void)
+{
+ if (pthread_create(>od_thread, NULL, gtod_thread_main, NULL)) {
+ perror("Can't create gtod thread");
+ return 1;
+ }
+ if (pthread_detach(gtod_thread) < 0) {
+ perror("Can't detatch gtod thread");
+ return 1;
+ }
+
+ fio_mutex_down(startup_mutex);
+ return 0;
+}
+