Your pthread_attr_setschedparam
call is failing with "invalid parameter". Your program will start with the default linux scheduling policy of SCHED_OTHER
. You can't change the priority of SCHED_OTHER
.
From man (2) sched_setscheduler
:
SCHED_OTHER can only be used at static priority 0. SCHED_OTHER is the standard Linux time-sharing scheduler that is intended for all processes that do not require special static priority real-time mechanisms.
If you change the policy in the pthread attribute to another kind of schedule prior to attempting to change the priority your program will work. Something like
for (i = 0;i < 5;i++)
{
policy = SCHED_RR;
error = pthread_attr_setschedpolicy(tattr, policy);
// insert error handling
error = pthread_attr_getschedparam(tattr, ¶m);
// insert error handling
// yada yada yada ...
}