# Relation between task priority and the scheduling interval 

**URL:** <https://forums.freertos.org/t/relation-between-task-priority-and-the-scheduling-interval/6344>\
**Category:** Kernel\
**Created:** [January 11, 2017, 1:32pm UTC](https://forums.freertos.org/t/relation-between-task-priority-and-the-scheduling-interval/6344 "2017-01-11T13:32:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 11, 2017, 1:32pm UTC](https://forums.freertos.org/t/relation-between-task-priority-and-the-scheduling-interval/6344/1 "2017-01-11T13:32:25Z")

</div>

**[eswdev14](https://sourceforge.net/u/eswdev14/)** wrote on [Wednesday, January 11, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/181dcdea/#a0b3):

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

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [January 11, 2017, 5:49pm UTC](https://forums.freertos.org/t/relation-between-task-priority-and-the-scheduling-interval/6344/2 "2017-01-11T17:49:12Z")

</div>

**[hs2sf](https://sourceforge.net/u/hs2sf/)** wrote on [Wednesday, January 11, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/181dcdea/#c793):

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.

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [January 12, 2017, 11:52am UTC](https://forums.freertos.org/t/relation-between-task-priority-and-the-scheduling-interval/6344/3 "2017-01-12T11:52:06Z")

</div>

**[richard\_damon](https://sourceforge.net/u/richard_damon/)** wrote on [Thursday, January 12, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/181dcdea/#c1ca):

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.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 12, 2017, 2:42pm UTC](https://forums.freertos.org/t/relation-between-task-priority-and-the-scheduling-interval/6344/4 "2017-01-12T14:42:56Z")

</div>

**[eswdev14](https://sourceforge.net/u/eswdev14/)** wrote on [Thursday, January 12, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/181dcdea/#c793/50d0):

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!

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [January 12, 2017, 3:47pm UTC](https://forums.freertos.org/t/relation-between-task-priority-and-the-scheduling-interval/6344/5 "2017-01-12T15:47:19Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, January 12, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/181dcdea/#c793/50d0/a4bd):

Hi Max - have a look here:  
[http://www.freertos.org/Documentation/RTOS\_book.html](http://www.freertos.org/Documentation/RTOS_book.html)

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [January 12, 2017, 6:40pm UTC](https://forums.freertos.org/t/relation-between-task-priority-and-the-scheduling-interval/6344/6 "2017-01-12T18:40:30Z")

</div>

**[hs2sf](https://sourceforge.net/u/hs2sf/)** wrote on [Thursday, January 12, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/181dcdea/#4eed):

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…

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 12, 2017, 9:16pm UTC](https://forums.freertos.org/t/relation-between-task-priority-and-the-scheduling-interval/6344/7 "2017-01-12T21:16:17Z")

</div>

**[simonjwright](https://sourceforge.net/u/simonjwright/)** wrote on [Thursday, January 12, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/181dcdea/#c1ca/996c):

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

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [January 12, 2017, 9:27pm UTC](https://forums.freertos.org/t/relation-between-task-priority-and-the-scheduling-interval/6344/8 "2017-01-12T21:27:24Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, January 12, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/181dcdea/#c1ca/996c/4cfa):

Depends how you defined round robin scheduling. configUSE\_TIME\_SLCICING  
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.
