MDK-ARM Keil, MDK-ARM Datasheet - Page 20

KIT REALVIEW MCU DEVELOPMENT

MDK-ARM

Manufacturer Part Number
MDK-ARM
Description
KIT REALVIEW MCU DEVELOPMENT
Manufacturer
Keil
Type
Compiler and IDEr
Datasheets

Specifications of MDK-ARM

For Use With/related Products
ARM MCUs
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
20
Chapter 2. Developing With an RTOS
not to add the function entry and exit code. This code would normally manage
the native stack. Since the RTX scheduler handles this function, we can safely
remove this code. This saves both code and data memory and increases the
overall performance of the final application.
An RTOS-based program is made up of a number of tasks, which are controlled
by the RTOS scheduler. This scheduler is essentially a timer interrupt that allots
a certain amount of execution time to each task. So task1 may run for 100ms
then be de-scheduled to allow task2 to run for a similar period; task 2 will give
way to task3, and finally control passes back to task1. By allocating these slices
of runtime to each task in a round-robin fashion, we get the appearance of all
three tasks running in parallel to each other.
Conceptually we can think of each task as performing a specific functional unit
of our program, with all tasks running simultaneously. This leads us to a more
object-orientated design, where each functional block can be coded and tested in
isolation and then integrated into a fully running program. This not only imposes
a structure on the design of our final application but also aids debugging, as a
particular bug can be easily isolated to a specific task. It also aids code reuse in
later projects. When a task is created, it is allocated its own task ID. This is a
variable, which acts as a handle for each task and is used when we want to
manage the activity of the task.
OS_TID id1, id2, id3;
In order to make the task-switching process happen, we have the code overhead
of the RTOS and we have to dedicate a CPU hardware timer to provide the
RTOS time reference. For ARM7 and ARM9 this must be a timer provided by
the microcontroller peripherals. In a Cortex-M microcontroller, RTX will use the
SysTick timer within the Cortex-M processor. Each time we switch running
tasks the RTOS saves the state of all the task variables to a task stack and stores
the runtime information about a
Task Control Block
Task Stack
task in a Task Control Block. The
“context switch time”, that is, the
Priority & State
Context
time to save the current task state
and load up and start the next task,
is a crucial value and will depend
on both the RTOS kernel and the
design of the underlying hardware.
Task

Related parts for MDK-ARM