through a discussion of another problem, see Debugging a strange error, which depends on the selected scheduler , I came across some questions about scheduling my threads. I am on Linux 2.6.x working with root privileges and using pthreads to do side-effects in a critical urgent application written in C / C ++.
I will try to give some short, boiled, fragments to explain my question:
Basically, I do somewhere in the beginning:
struct sched_param sp; memset(&sp, 0, sizeof(sched_param)); sp.sched_priority = 99; sched_setscheduler(getpid(), SCHED_RR, &sp);
I understand that this is the code that switches my program to using the RR-Scheduler, which runs on max. a priority.
When starting pthread, I do:
sched_param param; pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); pthread_attr_getschedparam(&attr, ¶m); param.sched_priority = priority; pthread_attr_setschedpolicy(&attr, SCHED_RR); pthread_attr_setschedparam(&attr, ¶m);
I understand this to be code that switches the thread that RR-Scheduler will run using the priority specified in "priority". Will this work equivalently if main does not switch the scheduler?
What I do not understand if it is necessary to call this code basically? (The main function does nothing but launch everything, and then blocks keyboard input). Where can I find the exact documentation of how this works. I don't think manpages do a good job explaining the background.
Thanks in advance.