My application creates a helper pthread that I need to have run at a higher priority than the main thread.
I tried to set the priority of the created thread like this:
struct sched_param param;
pthread_attr_t tattr;
pthread_attr_init(&tattr);
pthread_attr_getschedparam(&tattr, ¶m);
param.sched_priority = sched_get_priority_max(SCHED_RR);
pthread_attr_setschedparam(&tattr, ¶m);
pthread_create(&helper_thread, &tattr, helper_main, NULL);
But the pthread_attr_setschedparam
call is returning EINVAL.
I'm not sure what I'm doing wrong here. Is this even the right general approach?
I don't really care how it gets done I just need the new thread to have a higher priority than the original one.