Compiling And Linking With Rtx51 - Keil RTX51 Manual

Table of Contents

Advertisement

RTX Tiny
void job1 (void) _task_ 1 {
while (1) {
os_wait (K_SIG, 0, 0);
counter1++;
}
}
In the above example, job1 waits until it receives a signal from any other task. When it
does receive a signal, it will increment counter1 and again wait for another signal.
job0 continuously increments counter0 until it overflows to 0. When that happens,
job0 sends a signal to job1 and RTX51 marks job1 as ready for execution. job1
will not be started until RTX51 gets its next timer tick.
Priorities and Preemption
One disadvantage of the above program example is that job1 is not started immediately
when it is signaled by job0. In some circumstances, this is unacceptable for timing rea-
sons. RTX51 allows you to assign priority levels to tasks. A task with a higher priority
will interrupt or pre-empt a lower priority task whenever it becomes available. This is
called preemptive multitasking or just preemption.
NOTE
You can modify the above function declaration for job1 to give it a higher priority than
job0. By default, all tasks are assigned a priority level of 0. This is the lowest priority
level. The priority level can be 0 through 3. The following example shows how to define
job1 with a priority level of 1.
void job1 (void) _task_ 1 _priority_ 1 {
while (1) {
os_wait (K_SIG, 0, 0);
counter1++;
}
}
Now, whenever job0 sends a signal to job1, job1 will start immediately.

Compiling and Linking with RTX51

RTX51 is fully integrated into the C51 programming language. This makes generation of
RTX51 applications very easy to master. The previous examples are executable RTX51
programs. You do not need to write any 8051 assembly routines or functions. You only
have to compile your RTX51 programs with C51 and link them with the BL51
Linker/Locator. For example, you should use the following command lines if you are
using RTX51 Tiny.
C51 EXAMPLE.C
BL51 EXAMPLE.OBJ RTX51TINY
Use the following command lines to compile and link using RTX51.
Preemption and priority levels are not supported by RTX51 Tiny.
/* loop forever */
/* wait for a signal */
/* update the counter */
/* loop forever */
/* wait for a signal */
/* update the counter */
11
1

Advertisement

Table of Contents
loading

Table of Contents