Single Task Program; Round-Robin Program; Round-Robin Scheduling With Rtx51 - Keil RTX51 Manual

Table of Contents

Advertisement

8

Single Task Program

1
A standard C program starts execution with the main function. In an embedded applica-
tion, main is usually coded as an endless loop and can be thought of as a single task which
is executed continuously. For example:
int counter;
void main (void) {
counter = 0;
while (1) {
}
}

Round-Robin Program

A more sophisticated C program may implement what is called a round-robin pseudo-
multitasking scheme without using a RTOS. In this scheme, tasks or functions are called
iteratively from within an endless loop. For example:
int counter;
void main (void) {
counter = 0;
while (1) {
}
}

Round-Robin Scheduling With RTX51

RTX51 also performs round-robin multitasking which allows quasi-parallel execution of
several endless loops or tasks. Tasks are not executed concurrently but are time-sliced.
The available CPU time is divided into time slices and RTX51 assigns a time slice to
every task. Each task is allowed to execute for a predetermined amount of time. Then,
RTX51 switches to another task that is ready to run and allows that task to execute for a
while. The time slices are very short, usually only a few milliseconds. For this reason, it
appears as though the tasks are executing simultaneously.
counter++;
check_serial_io ();
process_serial_cmds ();
check_kbd_io ();
process_kbd_cmds ();
adjust_ctrlr_parms ();
counter++;
RTX51 Real-Time Operating System
/* repeat forever */
/* increment counter */
/* repeat forever */
/* process serial input */
/* process keyboard input */
/* adjust the controller */
/* increment counter */

Advertisement

Table of Contents
loading

Table of Contents