Multiple scheduling policies usage

217 views Asked by At

Can we use SCHED_OTHER and SCHED_RR for two threads, if so how will the CPU handle the threads with policy of Non-Realtime and Realtime.

2

There are 2 answers

0
Ciro Santilli OurBigBook.com On

What @janneb said is true for the Linux implementation of POSIX. But since this question was also tagged posix, I shall quote what POSIX 7 says about it:

The effect of scheduling threads with the SCHED_OTHER policy in a system in which other threads are executing under SCHED_FIFO, SCHED_RR, or SCHED_SPORADIC is implementation-defined.

So what I can interpret from that is that POSIX does not specify what happens.

2
janneb On

The realtime thread (with SCHED_RR, that is) will always preempt the non-realtime one (with SCHED_OTHER, that is).

In other words, the SCHED_OTHER thread will only get a chance to run when the SCHED_RR thread is blocked.