As a task executes it utilizes the processor / microcontroller registers and accesses RAM and ROM just as any other program. These resources together (the processor registers, stack, etc.) comprise the task execution context.
A task is a sequential piece of code - it does not know when it is going to get suspended (swapped out or switched out) or resumed (swapped in or switched in) by the kernel
and does not even know when this has happened. Consider the example of a task being suspended immediately before executing an
instruction that sums the values contained within two processor registers.
While the task is suspended other tasks will execute and may modify the processor register values. Upon resumption the task
will not know that the processor registers have been altered - if it used the modified values the summation would result in an
To prevent this type of error it is essential that upon resumption a task has a context identical to that immediately prior to
its suspension. The operating system kernel is responsible for ensuring this is the case - and does so by saving the context of
a task as it is suspended. When the task is resumed its saved context is restored by the operating system kernel prior to its
execution. The process of saving the context of a task being suspended and restoring the context of a task being resumed is
called context switching.
Next: RTOS Fundamentals - Real Time Applications
Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2015 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd..
See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.