#define _GNU_SOURCE /* or _BSD_SOURCE or _SVID_SOURCE */ #include #include #include #include #include #define N 10000 void* otherthread(void* dummy) { unsigned i; while (1) { sched_yield(); pthread_testcancel(); } return NULL; } void timesched(int fd) { char buf[5]; struct timeval tv0, tv1; double t; int i; pthread_t thr; pthread_create(&thr, NULL, otherthread, NULL); gettimeofday(&tv0, NULL); for (i=0;i