I have created a thread in my Linux application, using pthread_create(). I would like to let this thread run at very very low priority as there are some real time threads running in the same application. The following is the code I have in the thread function itself:
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
/* Trying to set lowest priority possible for this thread */
param.sched_priority = 0;
ret = pthread_setschedparam(pthread_self(), SCHED_IDLE, ¶m);
if (!ret)
printf("Successfully set sched policy of thread\n");
I want to confirm if the above code is okay or not. Does it guarantee that my thread will not be given higher priority when compared to the other real time threads. Please suggest if any changes are required. FYI, the code runs on an embedded platform.