Example #1
0
int main() {
    int rc;
    struct timespec tp, tp2, request = { 1, 0 }, remain;

    test_clock_gettime();

    test_clock_getres("          CLOCK_REALTIME", CLOCK_REALTIME);
    test_clock_getres("         CLOCK_MONOTONIC", CLOCK_MONOTONIC);
    test_clock_getres("CLOCK_PROCESS_CPUTIME_ID", CLOCK_PROCESS_CPUTIME_ID);
    test_clock_getres(" CLOCK_THREAD_CPUTIME_ID", CLOCK_THREAD_CPUTIME_ID);

    test_clock_settime();

    test_clock_nanosleep();

    getntptimeofday(&tp, NULL);
    rc = nanosleep(&request, &remain);
    getntptimeofday(&tp2, NULL);

    if (rc != 0) {
        printf("remain: %d.%09d\n", (int) remain.tv_sec, (int) remain.tv_nsec);
    }

    printf("%d.%09d\n", (int) tp.tv_sec, (int) tp.tv_nsec);
    printf("%d.%09d\n", (int) tp2.tv_sec, (int) tp2.tv_nsec);
    printf("sleep %d ms\n\n", (int) timespec_diff_as_ms(&tp, &tp2));

    test_apc();

    return 0;
}
int main(int argc, char *argv[])
{
    test_clock_nanosleep();

    return 0;
}