4

I'm a bit confused between thread vs process scheduling.

I've read about process scheduling policies at

http://man7.org/linux/man-pages/man2/sched_getscheduler.2.html

and I've read about thread scheduling at

http://man7.org/linux/man-pages/man3/pthread_getschedparam.3.html

Do threads inherit scheduling policy from their process? Is it possible to set process scheduling to SCHED_OTHER, and then set one of that process's threads to SCHED_FIFO ? I understand the policies independently but don't understand the thread/process relationship. Nay insight?

Brandon Yates
  • 2,022
  • 3
  • 22
  • 33

1 Answers1

5

Linux does not support process scheduling at all. Scheduling is entirely on a thread basis. The sched_* functions incorrectly modify the thread scheduling parameters of the target thread id instead of the scheduling parameters of a process. See:

http://sourceware.org/bugzilla/show_bug.cgi?id=14829 and http://sourceware.org/bugzilla/show_bug.cgi?id=15088

R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
  • Thanks for the reply, though I think I'm even more confused now! Surely there is some mechanism by which the kernel decides what process to run when, regardless of what we call it. Is it the case then that the only way to alter process execution times is to change the niceness level with setpriority()? – Brandon Yates Aug 09 '13 at 01:57
  • 2
    Each thread is scheduled independently according to its scheduling policy. All threads, whether they are part of the same process or different processes, compete in the same scheduling contention scope. – R.. GitHub STOP HELPING ICE Aug 09 '13 at 02:10
  • That makes sense. Thanks. Honestly when you put it that way it's so simple and concise... I can't believe it's so hard to find this stuff out. – Brandon Yates Aug 09 '13 at 02:49
  • I'm still a bit confused. Since schedulers try to balance IO vs CPU bound processes in the queues and , it makes (well, was making) for sense to first prioritise processes and then pick up the thread with the highest priority among others (in the same process). Now, I'm thinking of all of the queues involved in scheduling with full of threads instead of processes which sounds/looks slightly different then scheduler descriptions which always mentions scheduling as process scheduling. – stdout Jun 05 '17 at 12:28