i most certainly will get some of this wrong but i will try to answer.
I agree with you it is confusing especially how priority fits in to the RT picture if at all.and of course it's changing all the time now there is
(policy) == SCHED_NORMAL
(policy) == SCHED_FIFO
(policy) == SCHED_RR
(policy) == SCHED_ISO_RR
(policy) == SCHED_ISO_FIFO
realtime FIFO threads are the highest priority and are not preemptable and don't give up the CPU to anything except a new realtime FIFO thread or if the FIFO thread blocks. FIFOs don't get timeslices and are not subject to the clock. They just run until they are done. So that aspect of priority in the schedular namely larger timeslice for higher priority is out the window.
I think the nice value for rt tasks is calculated but has no effect unless the thread becomes SCHED_NORMAL.Only one valid priority for SCHED_FIFO and SCHED_RR and are set by setscheduler() i think.
Code:
switch (policy) {
case SCHED_FIFO:
case SCHED_RR:
ret = 1;
break;
case SCHED_NORMAL:
ret = 0;
}
RR threads are like FIFO threads but they use timeslices.
Code:
if (unlikely(rt_task(p))) {
/*
* RR tasks need a special form of timeslice management.
* FIFO tasks have no timeslices.
*/
if ((p->policy == SCHED_RR) && !--p->time_slice) {
p->time_slice = task_timeslice(p);
p->first_time_slice = 0;
set_tsk_need_resched(p);
/* put it at the end of the queue: */
dequeue_task(p, rq->active);
enqueue_task(p, rq->active);
}
If multiple realtime RR threads are running, each one is run for its timeslice, after which it goes to the end of the list of realtime RR threads.