Copyright (C) 2003 - 2007 Richard Barry ` www.FreeRTOS.org
Page 1 of 128
Chapter 16 – FreeRTOS
Table of Contents
Section 1: Synopsis.............................................................................................................5
Multi tasking...................................................................................................................5
Features........................................................................................................................... 5
Design Philosophy .......................................................................................................... 5
Section 2: RTOS Fundamentals.......................................................................................... 6
Multitasking....................................................................................................................6
Multitasking Vs Concurrency......................................................................................... 6
Scheduling....................................................................................................................... 7
Context Switching........................................................................................................... 8
Real Time Applications .................................................................................................. 9
Real Time Scheduling................................................................................................... 11
Section 3: RTOS Implementation..................................................................................... 13
Detailed Description ..................................................................................................... 13
C Development Tools.................................................................................................... 13
The RTOS Tick............................................................................................................... 13
GCC Signal Attribute ..................................................................................................... 14
GCC Naked Attribute..................................................................................................... 16
FreeRTOS Tick Code.................................................................................................... 17
The AVR Context ........................................................................................................... 18
Restoring the Context ....................................................................................................... 20
Putting It All Together.................................................................................................... 21
RTOS Context Switch - Step 1 .................................................................................... 22
Prior to the RTOS tick interrupt.................................................................................... 22
RTOS Context Switch - Step 2 .................................................................................... 22
The RTOS tick interrupt occurs.................................................................................... 22
RTOS Context Switch - Step 3 .................................................................................... 23
The RTOS tick interrupt executes................................................................................. 23
RTOS Context Switch - Step 4 .................................................................................... 24
Incrementing the Tick Count........................................................................................ 24
RTOS Context Switch - Step 5 .................................................................................... 25
The TaskB stack pointer is retrieved ............................................................................ 25
RTOS Context Switch - Step 6 .................................................................................... 25
Restore the TaskB context ............................................................................................ 25
RTOS Context Switch - Step 7 .................................................................................... 26
The RTOS tick exits...................................................................................................... 26
Tasks and Co-routines .................................................................................................. 27
Characteristics of a 'Task' ......................................................................................... 28
Characteristics of a 'Co-routine'................................................................................ 28
Tasks................................................................................................................................ 29
Task States ................................................................................................................ 29
Task Priorities........................................................................................................... 31