Вы находитесь на странице: 1из 6

A Jitter-Free Kernel for Hard Real-Time Systems

Christo Angelov, Jesper Berthing

Mads Clausen Institute for Product Innovation, University of Southern Denmark


Grundtvigs Alle 150, 6400 Soenderborg, Denmark
E-mail: {angelov, berthing}@mci.sdu.dk

Abstract. The paper presents advanced task management techniques featuring


Boolean vectors and bitwise vector operations on kernel data structures in the
context of the HARTEXTM hard real-time kernel. These techniques have been
consistently applied to all aspects of task management and interaction. Hence,
the execution time of system functions no longer depends on the number of
tasks involved, resulting in predictable, jitter-free kernel operation. This
approach has been further extended to time management resulting in a new type
of kernel component, which can be used to implement timed multitasking - a
novel technique providing for jitter-free execution of hard real-time tasks.

1 Introduction

Modern embedded systems have to satisfy stringent requirements with respect to


system safety and predictability. Currently, there are two approaches for engineering
predictable embedded systems: static scheduling vs. predictable dynamic scheduling.
The former approach is widely used with safety-critical systems. However, static
scheduling has a major disadvantage: its use results in closed, non-reusable systems
that are difficult to reconfigure and maintain. This is in contradiction to the
requirement for an open system architecture that has to provide support for software
reuse as well as in-site and on-line reconfiguration.
The latter approach is more promising but it requires the development of a new
generation of safe real-time kernels, which provide a secure and predictable
environment for application tasks through predictable task scheduling and interaction,
extensive timing and monitoring facilities, and last but not least - predictable
behaviour of the kernel itself. Such functionality cannot be efficiently accomplished
using conventional kernel algorithms and data structures, i.e. linked lists used to
implement system queues. Extensive linked list processing introduces substantial and
largely varying overhead known as kernel jitter [4].
This paper presents a novel kernel design using Boolean vectors (bit-strings) in
order to implement system queues. Consequently, queues can be processed through
bitwise Boolean operations resulting in jitter-free operation and substantial reduction
of kernel overhead. That approach has been consistently applied to all aspects of task
management and interaction: task scheduling, task execution request generation, task
synchronization and communication [2, 3]. It has been further extended to time
management resulting in a new type of kernel component - the Static Time Manager,
2 Christo Angelov, Jesper Berthing

which can be used to implement Timed Multitasking - a novel computational model


providing for jitter-free execution of hard real-time tasks [5].
The paper focuses on advanced task and time management based on Boolean
vector processing as implemented in HARTEXTM - a timed-multitasking version of the
HARTEX kernel [2]. The paper is organized as follows: Section 2 gives an overview
of the kernel architecture and functionality. Section 3 presents task management using
Boolean vectors. Section 4 presents advanced time management and the so-called
Static Time Manager in the context of timed multitasking. The last section contains
concluding remarks highlighting the implications of the developed kernel
architecture.

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

3 Jitter-Free Task Management

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]).

4 Time Management for Jitter-Free Execution of Real-Time Tasks

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:

with every clock tick do {


update current time;
if ( current_time < schedule[I].offset) return;
else {
generate a deadline violation vector if some
tasks_with_deadline have not yet finished
execution, and disable those tasks;
execute the output_drivers of tasks that have
finished execution;
release tasks specified by the tasks_to_release
vector (if not disabled);
execute the input_drivers of released tasks;
I = I + 1 (mod (schedule length));
invoke the Task Manager;
}
}

The above algorithm is executed using Boolean vector processing techniques, as


follows:
- The deadline violation vector is generated by ANDing the ATV and
tasks_with_deadline vectors. That vector is sent to the Deadline Exception Handler
(if non-zero), in case some of the tasks specified by the tasks_with_deadline vector
have not finished execution, and these are disabled by resetting their ETV bits.
- The output drivers specified by the corresponding vector are executed, i.e. the output
drivers of tasks that have a deadline at that instant. However, a driver is executed
only if the task has finished before its deadline. This can be accomplished by
disabling certain drivers as indicated by the task deadline violation vector.
- Tasks specified by the task_to_release vector are released, i.e. registered in the ATV
if enabled (see algorithm given in section 3).
- Input drivers specified by the corresponding vector are executed, and in particular -
the input drivers of those tasks that have been actually released at that time instant.
- Finally, the task manager is invoked in order to re-schedule the processor, since
some of the newly released tasks may have higher priority than the currently
running task.
6 Christo Angelov, Jesper Berthing

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

1. Angelov, C., Sierszecki, K.: Component-Based Design of Software for Distributed


Embedded Systems. Proc. The 10th IEEE International Conference on Methods and Models
in Automation and Robotics, Medzyzdroje, Poland (2004)
2. Angelov, C.K., Ivanov, I.E., Burns A.: HARTEX - a Safe Real-Time Kernel for Distributed
Computer Control Systems. Software: Practice and Experience, vol. 32, No 3, March (2002)
209-232
3. Berthing, J. and Angelov, C.: High-Performance Task Management and Interaction for Safe
Real-Time Kernels. CSI Seminar on Safety-Critical Software, Soenderborg (2003)
4. Burns, A., Tindell, K., Wellings, A.: Effective Analysis for Engineering Real-Time Fixed-
Priority Schedulers. IEEE Trans. on Soft. Eng., vol. 21 (1995) 475-480
5. Liu, J. and Lee, E.A.: Timed Multitasking for Real-Time Embedded Software: IEEE Control
Systems Magazine "Advances in Software Enabled Control", February (2003) 65-75

Вам также может понравиться