Task Switching; Events - Keil RTX51 Manual

Table of Contents

Advertisement

18

Task Switching

RTX51 Tiny 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 Tiny assigns a time slice
to every task. Each task is allowed to execute for a predetermined amount of time. Then,
RTX51 Tiny switches to another task that is ready to run and allows that task to execute
2
for a while. The duration of a time slice can be defined with the configurarion variable
TIMESHARING. Refer to chapter 3, RTX51 Tiny configuration for more information.
Rather then wait for a task' s time slice to expire, you can use the os_wait system function
to signal RTX51 Tiny that it can let another task begin execution. os_wait suspends the
execution of the current task and waits for a specified event to occur. During this time,
any number of other tasks may be executing.
The section of RTX51 Tiny which assigns the processor to a task is called the scheduler.
The RTX51 Tiny scheduler defines which task is running according to the following
rules:
The currently running task is interrupted if...
1.
The task calls the os_wait function and the specified event has not occurred.
2.
The task has executed for longer than the defined round-robin time-out.
Another task is started if...
1.
No other task is running.
2.
The task which is to be started is in the R

Events

The os_wait function of RTX51 Tiny supports the following event types:
S
IGNAL
T
IMEOUT
I
NTERVAL
:
Bit for task communication. A signal can be set or cleared using RTX51
Tiny system functions. A task can wait for a signal to be set before con-
tinuing. If a task calls the os_wait function to wait for a signal and if the
signal is not set, the task is suspended until the signal gets set. Then, the
task is returned to the R
:
A time delay which is started by the os_wait function. The duration of the
time delay is specified in timer ticks. The task who is calling the os_wait
funciton with a TIMEOUT value is suspended until the time delay is over.
Then, the task is returned to the R
: A interval delay which is started by the os_wait function. The interval delay
is also specified in in timer ticks. The difference to a timeout delay is that
the RTX51 timer is not reset. Therefore the event I
timer which is running permantly. An interval can be used if the task is to
be executed in synchronous intervals; a simple example is a clock.
Introduction to RTX51 Tiny
or T
-
EADY
IME
OUT
State and can begin execution.
EADY
State and can begin execution.
EADY
State.
works with a
NTERVAL

Advertisement

Table of Contents
loading

Table of Contents