--- cyclictest.c.orig 2005-11-24 13:33:21.000000000 +0100 +++ cyclictest.c 2006-03-17 10:50:26.000000000 +0100 @@ -24,12 +24,14 @@ #include #include #include +#include #include #include #include #include +#include /* Ugly, but .... */ #define gettid() syscall(__NR_gettid) @@ -158,7 +160,7 @@ void *timerthread(void *param) memset(&schedp, 0, sizeof(schedp)); schedp.sched_priority = par->prio; - sched_setscheduler(0, policy, &schedp); + pthread_setschedparam(pthread_self(), policy, &schedp); /* Get current time */ clock_gettime(par->clock, &now); @@ -265,7 +267,7 @@ out: /* switch to normal */ schedp.sched_priority = 0; - sched_setscheduler(0, SCHED_OTHER, &schedp); + pthread_setschedparam(pthread_self(), SCHED_OTHER, &schedp); stat->threadstarted = -1; @@ -396,6 +398,7 @@ int main(int argc, char **argv) int mode; struct thread_param *par; struct thread_stat *stat; + pthread_attr_t thattr; int i, ret = -1; if (geteuid()) { @@ -403,6 +406,8 @@ int main(int argc, char **argv) exit(-1); } + mlockall(MCL_CURRENT | MCL_FUTURE); + process_options(argc, argv); mode = use_nanosleep + use_system; @@ -442,7 +447,9 @@ int main(int argc, char **argv) par[i].stats = &stat[i]; stat[i].min = 1000000; stat[i].max = -1000000; - pthread_create(&stat[i].thread, NULL, timerthread, &par[i]); + pthread_attr_init(&thattr); + pthread_attr_setstacksize(&thattr, PTHREAD_STACK_MIN); + pthread_create(&stat[i].thread, &thattr, timerthread, &par[i]); stat[i].threadstarted = 1; }