Professional Documents
Culture Documents
1 Introduction
2 HARTEX Architecture
HARTEX (HArd Real-Time Executive for Control Systems) is a safe real-time kernel,
which has been conceived as an operational environment for component-based
applications conforming to the COMDES model of distributed computation [1, 2].
Subsequently, a number of versions have been developed, i.e. HARTEXAVR [3],
HARTEXµ and HARTEXTM - a timed multitasking version, which is presented in this
paper.
The HARTEX architecture exhibits a number of novel features, which are briefly
summarized below:
- Component-based architecture supporting kernel reconfiguration and scalability
- Integrated task and resource scheduling via the System Ceiling Priority Protocol – a
non-blocking synchronization protocol providing for predictable and efficient
management of shared resources
- Boolean vector processing of kernel data structures, resulting in very low overhead
and constant execution time of system functions, hence jitter-free operation of
kernel subsystems
- Predictable jitter-free execution of real-time tasks in a distributed timed multitasking
environment, using an advanced clock synchronization mechanism and a new type
of time manager - the Static Time Manager
- Event notification via Boolean vector semaphores, providing for the instantaneous
broadcast/multicast of events to multiple receiver tasks
- Integrated communication protocol supporting transparent content-oriented message
addressing within local and/or remote interactions, including both state message and
event message communication
However, the main innovation of the kernel is the use of Boolean vector
processing, whereby linked-list queues have been substituted by Boolean vectors,
resulting in efficient and highly deterministic (jitter-free) behaviour characterised by
very low overhead and constant execution time of kernel operations, independent of
the number of tasks involved.
The following discussion presents Boolean vector processing techniques for task
and time management used in the recently developed timed-multitasking version of
the HARTEX kernel.
A Jitter-Free Kernel for Hard Real-Time Systems 3
Task management is carried out in accordance with the state transition diagram shown
in Fig. 1-a. It consists of the active task superstate, as well as three other states -
suspended, inactive and disabled task. The active superstate encapsulates three other
states - ready, running and preempted task. It is only active tasks that are recognized
by the scheduler, which is the main component of the task manager.
Fig. 1. HARTEX state transition diagram and Boolean vector bit patterns
An extended task may be temporarily suspended while waiting for some kind of
event to take place, whereas basic tasks may never be suspended. A basic task will
switch to an inactive state upon exiting the system, and it will be eventually released
again. Finally, basic tasks may be temporarily or permanently disabled. However, this
action has a run-to-completion semantics: the task is actually disabled after it has
become inactive, i.e. after it has released its resources and left data structures in a
consistent state. Subsequently, such a task can be released again only after it has been
re-enabled.
Task management can be substantially speeded up by abandoning the traditional
linked-list implementation of the dispatch queue. Instead, it can be emulated using
two Boolean vectors - the Active Tasks Vector (ATV) and the Preempted Tasks Vector
(PTV) that have as many bits as there are tasks in the system. Vector bit position
represents task priority as well as task number, which is used as an index to a Task
Control Block (TCB) within the TCB table. Another vector of the same dimension is
used in order to define the tasks that are enabled in the system, i.e. the Enabled Tasks
Vector (ETV).
4 Christo Angelov, Jesper Berthing
The state encoding logic for various task states is shown in Fig. 1-b. It has been
specifically designed to reduce the execution time of task state transition operations
and corresponding task management primitives, which are effectively reduced to bit
manipulation. Moreover, the use of the above encoding technique makes it possible to
simultaneously execute multiple identical operations involving different tasks through
bitwise operations on Boolean vectors. This is done in constant time, no matter how
many tasks are involved in the operation, as illustrated by the primitive release(tasks).
The latter generates multiple execution requests for a subset of tasks specified by the
tasks argument vector:
release(tasks)
{
ATV = ATV OR (tasks AND ETV);
}
The execution time of the above function is in the (sub)microsecond range
depending on the platform used, e.g. 4 µs in an 8-bit ATmega 103 microcontroller
running at 4 Mhz and operating on 16-bit vectors. With linked-list queues, the same
operation might take from tens to hundreds of microseconds depending on the number
of tasks involved, even in relatively high-end processors, such as the 32-bit Motorola
68020 [4].
Likewise, task scheduling is facilitated by the Boolean vector data structure. The
task manager determines the highest priority active task to be executed by finding the
highest-priority non-zero bit in the ATV. This is done via a bit search procedure,
which takes constant time to execute, and in some processors this can be
accomplished with a single instruction (e.g. the Intel BSF instruction). In fact, the
scheduling algorithm is somewhat more involved because it implements integrated
task and resource scheduling using the System Ceiling Priority Protocol (for more
information see [3]).
This section presents static time management, which can be used to implement
precisely timed transactions in the context of Timed Multitasking – a novel
computational model combining the predictability of statically scheduled systems
with the flexibility of dynamically scheduled systems [5]. This model has been
recently extended for distributed embedded systems involving communication I/O
drivers, as defined in the COMDES framework [1].
Timed system transactions are conducted by means of the so-called Static Time
Manager (STM). This is a dedicated kernel component that executes a cyclic static
schedule with respect to timed input/output and task release actions. However,
released tasks are executed in a preemptive priority-based environment provided by
the HARTEXTM Task Manager. The above schedule may be implemented as a table
consisting of records corresponding to specific instants of the system (super)period.
Table records have the following format:
{ offset, tasks_with_deadline, output_drivers, tasks_to_release, input_drivers } ,
A Jitter-Free Kernel for Hard Real-Time Systems 5
where each instant is specified with an offset from the beginning of the superperiod.
Accordingly, tasks_with_deadline is a Boolean vector specifying the tasks whose
deadline expires at the time instant given by offset; output_drivers specifies the output
drivers to be executed at that instant if the corresponding task deadlines have not been
violated; tasks_to_release is another Boolean vector specifying tasks that have to be
released, and input_drivers specifies the input drivers to be executed at that same
instant.
The Static Time Manager processes the scheduling table in a cyclical tick-driven
manner that can be described with the following pseudocode:
It is obvious from the above discussion that the presented timing mechanism
implements a static schedule with respect to timed input/output and task release
actions, whose operation is largely similar to that of a rotating drum sequencer used in
some mechanical devices. Therefore, it has been denoted as the Static Time Manager
(and alternatively – the Drum Sequencer).
With this algorithm task I/O drivers are atomically executed at precisely specified
time instants, whereas tasks are executed in a preemptive priority-driven environment
and may have termination jitter. However, jitter is effectively eliminated, as long as
tasks finish execution before their deadlines.
5 Conclusion
The paper has presented advanced task and time management featuring Boolean
vectors and parallel (bitwise) vector operations on kernel data structures, in the
context of the timed-multitasking version of the HARTEX real-time kernel. The use of
Boolean vectors has resulted in the elimination of linked lists, hence low overhead
and jitter-free execution of kernel operations whose duration depends no longer on the
number of tasks involved.
This is an outstanding feature with important implications. On the one hand, low
kernel overhead results in faster task response and increased processor schedulability.
On the other hand, constant duration of kernel operations makes it possible to
precisely estimate task response times taking into account kernel execution effects,
which will contribute to higher systems safety and predictability. Ultimately, this
technique has made it possible to efficiently implement the timed multitasking
paradigm, resulting in jitter-free execution of hard real-time tasks in single-computer
and distributed environments.
The presented techniques have been validated in a series of distributed motion
control experiments, and jitter-free behaviour has been demonstrated while executing
transactions with one-period delay from sampling to actuation, transactions with
offsets, as well as distributed transactions with fully decoupled (pipelined) tasks.
References