Reputation: 95
Say I have a process with 4 threads, and I want them to run according to specific scheduling algorithm. I searched and found pthread_setschedparam
and sched_setschedparam
functions for selecting an algorithm and setting priorities of a thread, but I saw one thing that was unclear - pthread_setschedparam
takes a thread name and sets it's own scheduling policy. What does that mean specifically, since I thought all threads within a process are scheduled according to one policy, which is set for the entire process.
Does that mean then that if I use sched_setschedparam
and set a policy (since it refers to a process via it's PID) it will ensure that threads within that process run according to selected scheduling policy?
Code I'm writing is for Linux, I was using boost but had to resort to pthreads for this part.
Upvotes: 4
Views: 2295
Reputation: 477040
pthread_setschedparam
sets the scheduling parameters for a single thread. sched_setscheduler
sets the scheduling parameters for an entire process. Different threads can indeed have different scheduling policies.
Upvotes: 4