Relation between task priority and the scheduling interval

Hi all, I’am relatively a beginner with using FreeRTOS. I have a general, but important question about FreeRTOS and its scheduling interval. In what way is there a relation between the assigned task priority and its corresponding task schedule interval used by the FreeRTOS scheduler? Is there something to say about for example taskX has a priority of 4 and the corresponding scheduling task interval is say 3ms? Any help in guiding me I will appreciate! Thanks, Max

Relation between task priority and the scheduling interval

prio and time slice / quantum are different things. There is no direct relationship in the sense you describe. Which higher level problem do you want to solve ? For example a periodic task can be setup by using a timer or just a timeout and choosing a prio matching your runtime system requirements.

Relation between task priority and the scheduling interval

FreeRTOS has a fixed ftask scheduling interval of 1 Tick, i.e. every tick the current running task is put at the end of the ready queue for its execution priority and the next task with the same priority (which might be the task just running) is then run. Since the class of machine that FreeRTOS runs on do not normally use virtual memory, there is little need to have lower priority tasks have a larger execution quantum.

Relation between task priority and the scheduling interval

Thanks for the answer! But if I understand it correctly, can I use several hardware timers of the ARM microcontroller to have periodic tasks with FreeRTOS? If no, how can I configure/tailor FreeRTOS to have several periodic tasks which would be scheduled in say 2, 3 and 5ms in my microcontroller application? And how about configuring the SysTick timer used by the FreeRTOS scheduler? An example would be very helpful!

Relation between task priority and the scheduling interval

Hi Max – have a look here: http://www.freertos.org/Documentation/RTOS_book.html

Relation between task priority and the scheduling interval

Well, the most simple (hence often the best) approach could be to configure the SysTick period less or equal to your minimum period because Systick is the minimum resolution of timers resp. timeouts and use a dedicated task per rate. The periodic tasks are merely simple loops waiting for it’s timeout to expire, doing housekeeping and wait again… The tasks can be prioritized accordingly and you’re fine 😉 Sure – there a number of alternative approaches, but probably with the price of increasing complexity e.g using hardware timers with ISRs usually signalling events to task context, etc. On the other hand using dedicated peridiodic tasks costs a bit more RAM needed for the task stacks..

Relation between task priority and the scheduling interval

You only get round-robin scheduling if configUSE_TIME_SLICING is 1.

Relation between task priority and the scheduling interval

Depends how you defined round robin scheduling. configUSETIMESLCICING prevents a context switch between tasks of equal priority just because of a tick interrupt – but tasks of equal priority will still take turns to execute.