je la source suivante qui aiment avoir la priorité SCHED_RR 90:sched_setscheduler est pour tous les threads ou thread principal?
int main(int argc, char** argv)
{
const char *sched_policy[] = {
"SCHED_OTHER",
"SCHED_FIFO",
"SCHED_RR",
"SCHED_BATCH"
};
struct sched_param sp = {
.sched_priority = 90
};
pid_t pid = getpid();
printf("pid=(%d)\n",pid);
sched_setscheduler(pid, SCHED_RR, &sp);
printf("Scheduler Policy is %s.\n", sched_policy[sched_getscheduler(pid)]);
pthread_t tid ;
pthread_create(&tid , NULL, Thread1 , (void*)(long)3);
pthread_create(&tid , NULL, Thread2 , (void*)(long)3);
pthread_create(&tid , NULL, Thread3 , (void*)(long)3);
while(1)
sleep(100);
}
en coquille « top », je peux voir ce processus a PR avec -91, ressembler à cela fonctionne, Comme je sais, en Linux, thread1 et thread2 et thread3 sont différentes tâches du thread principal, ils partagent exactement la même mémoire virtuelle, je voudrais savoir dans ce test, dois-je besoin d'ajouter
pthread_setschedparam(pthread_self(), SCHED_RR, &sp);
pour tous thread1, thread2 et thread3 de sorte que tous ces 3 peuvent être schedu conduit avec SCHED_RR?! ou je n'ai pas besoin de faire ça?! et comment puis-je observer que thread thread1, thread2 et thread3 sont SCHED_RR ou SCHED_OTHER?!
Edit:
sudo chrt -v -r 90 ./xxx.exe
verra:
pid 7187's new scheduling policy: SCHED_RR
pid 7187's new scheduling priority: 90
comment puis-je être sûr que ce soit seulement pour fil conducteur?! ou tous les threads dans pid 7187 sont SCHED_RR politique?! et encore, comment l'observer?!