I have 2 threads,I want to thread2 running as the thread2 is idle,so I think
I should reduce the priority level of thread2 compared with thread1,below is my code to achive it,but after doing that the priority level of thread1 and thread2 is still same.
void*thread1()
{
pthread_attr_t attr;
int policy=SCHED_FIFO;
struct sched_param param;
pthread_attr_init( &attr );
pthread_getschedparam(pthread_self(),&policy,¶m);
param.sched_priority --;
pthread_attr_setschedparam(&attr, ¶m);
pthread_create (NULL, &attr, thread2, NULL);
}
You need to also change the inherit vs. explicit sched value…
pthread_attr_setinheritsched()
Take a look at that call.