# FIFO scheduling implementation

**URL:** <https://forums.freertos.org/t/fifo-scheduling-implementation/12714>\
**Category:** Kernel\
**Created:** [May 30, 2021, 9:26am UTC](https://forums.freertos.org/t/fifo-scheduling-implementation/12714 "2021-05-30T09:26:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![HosseinMohasselArjom](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/hosseinmohasselarjom/32/1679_2.png) [@HosseinMohasselArjom](https://forums.freertos.org/u/HosseinMohasselArjom)\
**Post date:** [May 30, 2021, 9:26am UTC](https://forums.freertos.org/t/fifo-scheduling-implementation/12714/1 "2021-05-30T09:26:40Z")

</div>

Hello. I wanted to implement FIFO scheduler in freeRTOS. I don’t know where and how to start. Is there any documentation about implementing FIFO or changing the scheduler in general?  
Thanks.

---

<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:** [May 30, 2021, 10:52am UTC](https://forums.freertos.org/t/fifo-scheduling-implementation/12714/2 "2021-05-30T10:52:25Z")

</div>

What exactly do you miss ? There is a good an detailed documentation of FreeRTOS including

> **[RTOS fundamentals](https://www.freertos.org/implementation/a00002.html)**
>
> A free RTOS. Title page for section describing an introduction to multitasking concepts.

describing scheduling aspects.

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [May 30, 2021, 11:08am UTC](https://forums.freertos.org/t/fifo-scheduling-implementation/12714/3 "2021-05-30T11:08:54Z")

</div>

You are welcome to modify taskSELECT\_HIGHEST\_PRIORITY\_TASK in tasks.c to whatever you wish.

---

<div class="post-metadata">

**Author:** ![HosseinMohasselArjom](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/hosseinmohasselarjom/32/1679_2.png) [@HosseinMohasselArjom](https://forums.freertos.org/u/HosseinMohasselArjom)\
**Post date:** [May 30, 2021, 11:12am UTC](https://forums.freertos.org/t/fifo-scheduling-implementation/12714/4 "2021-05-30T11:12:09Z")

</div>

How about arrival time?  
I checked the task.h for arrive or time keyword but seems I need to add it in order to implement FIFO?

---

<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:** [May 30, 2021, 11:18am UTC](https://forums.freertos.org/t/fifo-scheduling-implementation/12714/5 "2021-05-30T11:18:33Z")

</div>

If you refer to POSIX SCHED\_FIFO scheduling scheme I think FreeRTOS can simply be configured that way.  
Set configUSE\_PREEMPTION to 1 and configUSE\_TIME\_SLICING to 0 and there is also a `taskYIELD()` function.  
See also

> **[FreeRTOS - The Free RTOS configuration constants and configuration options -...](https://www.freertos.org/a00110.html#configUSE_TIME_SLICING)**
>
> FreeRTOS is a portable, open source, mini Real Time kernel. A free RTOS for small embedded systems. This page describes and explains the constants used to configure FreeRTOS.

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [May 30, 2021, 11:35am UTC](https://forums.freertos.org/t/fifo-scheduling-implementation/12714/6 "2021-05-30T11:35:56Z")

</div>

As a side note, FreeRTOS already schedules tasks FIFO but with respect to their respective task priority levels, and to my best knowledge, there is no recording of arrival time stamps (no need because the queue management “insert to end” to “remove from front” semantics imply FIFO already).

If you need unconditional FIFO scheduling, simply set all tasks to the same priority, and you are there.

If you want to experiment with more sophisticated algorithms such as anticipated shortest job first, you’ll need to do the time stamp management yourself. Study tasks.c and make the necessary modifications.

---

<div class="post-metadata">

**Author:** ![HosseinMohasselArjom](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/hosseinmohasselarjom/32/1679_2.png) [@HosseinMohasselArjom](https://forums.freertos.org/u/HosseinMohasselArjom)\
**Post date:** [June 5, 2021, 8:38am UTC](https://forums.freertos.org/t/fifo-scheduling-implementation/12714/7 "2021-06-05T08:38:19Z")

</div>

Hello.  
Are you sure there is USE\_TIME\_SLICING in config?  
I have downloaded freeRTOS from pmvanker and there is no such attribute there.

---

<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:** [June 5, 2021, 8:44am UTC](https://forums.freertos.org/t/fifo-scheduling-implementation/12714/8 "2021-06-05T08:44:40Z")

</div>

Just click on link I’ve posted before… and you‘’ll be there.  
As documented it’s enabled by default if not set/disabled in your FreeRTOSConfig.h.
