through the discussion of another problem, see Debugging strange error that depends on the selected scheduler, I ran into some questions about the scheduling of my threads. I am on Linux 2.6.x, running with root-rights and using pthreads to do parallel things in a timing critical application written in C/C++.
I'll try to give some short, boiled down, snippets to explain my question:
In main I somewhere at the beginning do:
struct sched_param sp;
memset(&sp, 0, sizeof(sched_param));
sp.sched_priority = 99;
sched_setscheduler(getpid(), SCHED_RR, &sp);
I understand this to be the code that switches my program to use the RR-Scheduler, running at max. priority.
When starting a 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 the code that switches the thread that's gonna be started to RR-Scheduler, using the priority given in 'priority'. Is that going to work equivalently if main would not switch the scheduler?
What I do not understand is, if it is necessary to call that code in main? (The main-function does not do anything than starting everything and then block on keyboard input.) Where can I find precise documentation of how this works. I don't think the manpages do a good job on explaining the background.
Thanks in advance.