if (clock_gettime(clockid, &start) == -1) { if (errno == EINVAL && check_skip(clockid)) return 0; return pr_perror("clock_gettime");
}
if (abs) {
now.tv_sec = start.tv_sec;
now.tv_nsec = start.tv_nsec;
}
now.tv_sec += 3600;
args.abs = abs;
args.lock = &lock;
ret = pthread_create(&thread, NULL, call_nanosleep, &args); if (ret != 0) {
pr_err("Unable to create a thread: %s", strerror(ret)); return 1;
}
/* Wait when the thread will call clock_nanosleep(). */
ok = 0; for (j = 0; j < 8; j++) { /* The maximum timeout is about 5 seconds. */
usleep(10000 << j);
/* Try to interrupt clock_nanosleep(). */
pthread_kill(thread, SIGUSR1);
usleep(10000 << j); /* Check whether clock_nanosleep() has been interrupted or not. */ if (pthread_mutex_trylock(&lock) == 0) { /**/
ok = 1; break;
}
} if (!ok)
pthread_kill(thread, SIGUSR2);
pthread_join(thread, NULL);
pthread_mutex_destroy(&lock);
if (_settime(CLOCK_MONOTONIC, 7 * 24 * 3600)) return 1; if (_settime(CLOCK_BOOTTIME, 9 * 24 * 3600)) return 1;
nsfd = open("/proc/self/ns/time_for_children", O_RDONLY); if (nsfd < 0) return pr_perror("Unable to open timens_for_children");
if (setns(nsfd, CLONE_NEWTIME)) return pr_perror("Unable to set timens");
ret = 0;
ret |= run_test(CLOCK_MONOTONIC, 0);
ret |= run_test(CLOCK_MONOTONIC, 1);
ret |= run_test(CLOCK_BOOTTIME_ALARM, 0);
ret |= run_test(CLOCK_BOOTTIME_ALARM, 1);
if (ret)
ksft_exit_fail();
ksft_exit_pass(); return ret;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.