Has anyone been able to get pthreads in Linux to run real-time? I've tried creating a new thread like so:
Code:
pthread_t real;
pthread_attr_t realAttributes;
sched_param fifoLevel;
fifoLevel.sched_priority = (sched_get_priority_max(SCHED_FIFO) +
sched_get_priority_min(SCHED_FIFO)) / 2;
pthread_attr_init(&realAttributes);
pthread_attr_setscope(&realAttributes, PTHREAD_SCOPE_SYSTEM);
pthread_attr_setinheritsched(&realAttributes, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&realAttributes, SCHED_FIFO);
pthread_attr_setschedparam(&realAttributes, &fifoLevel);
pthread_create(&real, &realAttributes, realmain, NULL);
The new thread just sleeps for a small amount (100 usec) of time and then reports the actual time slept. Although I run this app with sudo, it still won't do anything better than the 10-20 ms sleeps you get with standard user scheduling.
I've gotten this to work if you make the whole
process real-time, but why can't I just schedule one thread?
I am using 2.4.22-1.2188.nptl (Fedora Core 1). Thanks!