//...
pthread_attr_t attr;
pthread_attr_init( &attr ); // returns 0
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_JOINABLE ); // returns 0
#ifdef SCHED_RR // is defined!
if ( options && (options->flags & RTAUDIO_SCHEDULE_REALTIME) ) {
struct sched_param param;
int priority = options->priority;
int min = sched_get_priority_min( SCHED_RR );
int max = sched_get_priority_max( SCHED_RR );
if ( priority < min ) priority = min;
elseif ( priority > max ) priority = max;
param.sched_priority = priority;
pthread_attr_setschedparam( &attr, ¶m ); // returns 22...
pthread_attr_setschedpolicy( &attr, SCHED_RR ); // returns 0
// test begin:
int x = pthread_attr_getschedparam( &attr, ¶m );
int prio = param.sched_priority;
printf("\nPriority : %d \n", priority); // // returns 49
printf("\ngetsched : %d \n", x); // // returns 0
printf("\nT-Priority : %d \n", prio); // // returns 0
// test end
}
else
//...
I put these lines (test begin to test end) to the code, to see, if thread priority is really working. In the application "priority" is set (here) to 49. This test shows, that it is not working (prio = 0). Is there a mistake in the API or is my test-code wrong?
My second question: If I set process-priority (in the application), how does this value interact with thread priority? For all threads?