There is much of material available regarding priority preemptive scheduling on Google and Stackoverflow, but I am still having confusion regarding scheduling of infinite loop tasks in a priority preemptive scheduling kernel. Let's consider the following case:
An RTOS starts two tasks T1
and T2
with priority 50
and 100
respectively. Both tasks look like:
void T1()
{
while(1)
{
perform_some_task1();
usleep(100);
}
}
and
void T2()
{
while(1)
{
perform_some_task2();
usleep(100);
}
}
As far as I understood, the kernel will schedule T2
because of its higher priority and suspend T1
because of its lower priority. Now because T2
is an infinite loop, it will never relinquish CPU to T1
until some other high priority task preempts T2
.
BUT, it seems that my understanding is not correct because I have tested the above case in an RTOS and I get output on console printed by both tasks.
Can somebody comment on my understanding on the matter and the actual behavior of RTOS in above case?