 |
|
RTKernel |
กก |
-
RTKernel:Real-Time
Multitasking Kernel for DOS
|
|
- RTKernel is a powerful real-time multitasking system. It was
designed for software developers who wish to implement professional
process control applications on DOS computers or embedded systems.
Special care has been taken to ensure easy usage and excellent
run-time performance. RTKernel is compact (about 16k code, 6k data)
and provides the programmer with the basic tools needed to develop
efficient real-time software.
- RTKernel is a library or unit you can link to your application
program. It offers a number of functions and procedures to manage
tasks, semaphores, mailboxes, interrupts, etc. All RTKernel-tasks
normally run within a single program. An RTKernel-application consists
of a single EXE-file containing the kernel, the required drivers, and
all tasks. The EXE-file can be executed on any computer running DOS.
Although an RTKernel application has real-time multitasking
capabilities, it is a DOS program
|
Features
|
- Unlimited number of tasks
- Only about 500 bytes needed per task
- Task-switch time of about 6 microseconds (33 Mhz 486)
- Task-switch time independent of the number of tasks
- 64 priorities
- Cooperative and pre-emptive scheduling
- Event/interrupt-driven scheduling
- Task activations can be triggered by any hardware interrupt
- Time-Slicing can be enabled or disabled
- Changeable timer interrupt rate (0.1 to 55 ms)
- Measurement of time intervals with 1 microsecond resolution
- Support of math coprocessor/emulator
- Binary, counting, and resource semaphores
- Mailboxes (also known as message queues or pipes)
- Message passing (synchronous data transfer)
- Interrupt-driven driver for up to 36 serial ports
- Support of the 16550 UART chip family's FIFO buffer
- Drivers for timer, screen, keyboard, printer, and IPX (Novell LANs)
- Keyboard, hard disk, and floppy disk idle times usable by other
tasks
- No DOS reentrance problems
- RTKernel applications can be made memory-resident (TSRs)
- RTKernel applications can execute other DOS-programs using EXEC
- Safe and easy to use
- Special Debug Version to simplify software development
- Supports CodeView and Turbo Debugger
- Runs on any DOS computer
- ROMable
- Full source code available
- No run-time royalties
- English or German User's Manual
- Technical support available via Internet mailing list, email, or
phone free of charge.
|
RTKernel Tasks |
- An RTKernel-task is merely a C function or a Pascal procedure
without parameters. Task procedures / functions are programmed the
same way as any other procedure or function. At program
initialization, only one task is running - the main program, which
constitutes the Main Task. Although the program contains a real-time
system, it behaves like a "normal", sequential program at
this time. The Main Task can now register tasks with the kernel by
using appropriate procedure or function calls to the kernel. These
tasks are subsequently executed in parallel with the Main Task and any
other tasks.
Each task has a priority between 1 and 64 and its own stack. Higher
numbers indicate greater priority. All variables declared local to the
task procedure/function are allocated on the task's stack. The same is
true for the local variables of all procedures called by the task.
Several tasks can be started executing the same code; however, each is
allocated its own stack and thus its own local variables.
Since RTKernel-Tasks run within one program, Shared Code and Shared
Data are implemented automatically. All tasks can access global data
without restrictions. Code being used by more than one task is in
memory only once.
|
|
RTKernel Program Structure
|
Inter-Task
Communication
|
- The term inter-task communication refers to all methods enabling
tasks to exchange information or to synchronize with one another.
RTKernel offers three different mechanisms: semaphores, mailboxes, and
message-passing.
- Semaphores allow the exchange of signals for activation and
suspension of tasks. RTKernel supports counting, binary, and resource
semaphores. Resource semaphores are especially suited for the
efficient management of resources. A resource semaphore guarantees the
priority of a task occupying a resource to be at least the maximum of
the priorities of all other tasks also requiring the respective
resource. This technique is known as "priority inheritance".
It ensures that a high-priority task is never uneccessarily blocked by
a task of lower priority.
- With the aid of mailboxes, data can be exchanged between tasks. The
number of data records a mailbox can hold is configurable. Mailboxes
are especially suited for data buffering between tasks or between
interrupt handlers and tasks. In other systems, mailboxes are
frequently referred to as message queues or pipes. RTKernel's
message-passing corresponds to Ada's Rendezvous.
- Message-passing serves to exchange data directly between two tasks;
specifically, no data or signals will be buffered. This represents the
tightest coupling between tasks because the tasks involved are
synchronized by RTKernel for the exchange
|
The
Scheduler
|
- RTKernel maintains a task state for each task. The fundamental
states are:
- The Current task is the task currently running. Exactly one task
is in this state at any time after kernel initialization. If no
application task is ready to run, RTKernel activates its internal
Idle Task.
- All tasks ready to run are in the state Ready. These tasks
always have priorities less than or equal to the current task.
- Suspended tasks cannot run because they have been stopped
explicitly by a kernel call to Suspend. They can be made Ready
again by calling Resume.
- Tasks in the state Blocked cannot run because they are waiting
for an event (e.g., a semaphore signal or a message coming in at a
mailbox). These tasks can only be made Ready by another task or by
an interrupt handler.
- Tasks that have suspended themselves for a specific time
interval are in the state Delaying. They will be made Ready
automatically by the timer interrupt handler of RTKernel after the
delay has elapsed.
- Tasks waiting for the occurrence of an event with a time-out are
in the state Timed. Such a task will become Ready either if the
event occurs or if the time-out expires.
Tasks waiting for an event do not use CPU time under RTKernel,
because they are not in the state Ready or Current.
|
|
Task State Transitions
|
- RTKernel's scheduler is event-driven. It is not merely a
time-slicing system like many others. It was developed specifically
for real-time requirements and adheres to the following rules:
|
- Of all tasks in the state Ready, the task with the highest priority
runs.
- If the kernel has to choose among several Ready tasks having the
same priority, the task that hasn't run for the longest time is
activated.
- If several tasks are waiting for an event, they are activated upon
the occurrence of that event in the sequence of their respective
priorities.
- With the exception of time-slice task switches, a task switch is
only performed if otherwise rule 1 would be violated. Thus, the number
of task switches is minimized.
กก
|
- Since these rules are followed strictly, the behavior of the tasks
of a program can be controlled precisely. Both cooperative or
pre-emptive scheduling can be used. For programs requiring different
scheduling algorithms, the scheduler can be disabled temporarily.
Furthermore, task switches at fixed time intervals can be forced using
optional time-slicing.
|
Interrupts
|
- Interrupt handlers can suspend or activate tasks. This fact
qualifies RTKernel as "real-time". Interrupt handlers can be
programmed completely in C or Pascal. They can freely exchange signals
or data with tasks using semaphores or mailboxes. Semaphore or mailbox
operations may then initiate a task switch, if required. Interrupts
from any hardware can be processed; thus, third-party hardware not
supported by BIOS or DOS is supported by RTKernel.
- RTKernel comes with full source code for three interrupt handlers
(for the keyboard, the serial ports, and network events).
|
Debugging
|
- Since RTKernel is fully integrated into the run-time environments of
the supported compilers, all variants of Turbo Debugger and CodeView
can be used for debugging RTKernel applications without restrictions
|
|
Display of RTKernel Data Structures Using a Debugger
|
- As a further convenience to the programmer, RTKernel is delivered in
two versions. The Standard Version is optimized for minimum size and
best performance, while the Debug Version contains additional code for
parameter and consistency checks at run-time. The Debug Version
recognizes usage errors and produces corresponding error messages.
Moreover, the Debug Version offers numerous debugging aids. For
example, the current source code position can be found, all occupied
resources can be displayed, and the CPU time requirements can be
determined for each task. An especially powerful tool is the Kernel
Tracer, which can be used to record kernel and application events for
later analysis.
|
|
RTKernel Task List
|
- As an additional aid to debugging, RTKernel (Debug and Standard
Version) offers a number of informational functions. For example, a
list of all tasks currently running can be displayed, or the state of
a specific task can be queried. Furthermore, RTKernel keeps statistics
of the stack usage of all tasks. A complete list of all these
functions is innclided in the RTKernel Demo.
- When RTKernel detects an error, it displays the cause of the error,
the names of tasks, semaphores, and mailboxes involved, as well as the
corresponding source code position.
|
Drivers
|
- RTKernel is hardware-independent and only handles task management.
However, real-time applications are typically quite I/O-intensive;
therefore, hardware drivers are very important. Although RTKernel
applications can use DOS's device drivers and the BIOS without
restrictions, hardware drivers optimized specifically for a
multitasking environment will often yield significantly improved
performance. RTKernel comes with the following drivers (always with
full source code):
|
- Module Timer allows measurement of any number of
independent time intervals with a resolution of approximately 0.8
microseconds. A time interval can be up to 3.7 years long.
Furthermore, module Timer can modify the frequency of the timer
interrupt, which usually runs quite slowly at 18.2 Hertz.
- RTKeybrd installs its own keyboard interrupt
handler, so that tasks waiting for keyboard input don't consume CPU
time. Using RTKeybrd, a task can be activated immediately after a key
has been pressed. No CPU time is wasted by keyboard polling.
- A real-time system that can be stopped at any time using the
<PAUSE>-key is not fail-safe. Module KillKey
can inhibit such potentially dangerous keyboard input. Any keypress
can be redefined or simply suppressed. KillKey is normally used to
suppress keyboard input like Pause, Print-Screen, Ctrl-Alt-Del,
Ctrl-Break, etc.
- Using module RTTextIO, several screen windows can
be defined for parallel screen output by several tasks.
- The Spooler allows output of files to a parallel
printer in the background.
- Module CPUMoni monitors the CPU load of an
application. This information is especially important in time-critical
applications, since a real-time system must never approach a CPU load
of 100 percent.
- Module RTCom implements a complete interface to the
serial ports. Data can be sent and received interrupt-driven or by
polling at ports COM1 to COM4. Baud rates of 50 to 115200 bits/second
are supported. RTCom allocates a receive buffer for each port. The
size of each buffer is individually configurable up to 64 kbytes. If a
DigiBoard or Hostess card is installed, it can also be used. In this
case, up to 36 serial ports can be used simultaneously. RTCom
automatically recognizes the 16550-UART chip family and uses its
internal FIFO buffers. The communication protocols XOn/XOff, RTS/CTR,
and DSR/DTR are supported in two variants each.
- Module RTIPX implements a complete, high-level
interface to Novell's IPX protocol. It can be used on any workstations
in the net that have loaded an IPX driver. The data packets for
transmission can be up to 64 kbytes in size. RTIPX never needs to copy
data, even if data must be transmitted in more than one packet. This
results in the highest possible transfer rates. Unlike Novell's IPX
protocol, RTIPX guarantees the receipt of messages. Time-outs and
retries after transmission errors are handled transparently to the
application.
- Module IPC (Inter-Process Communication)
facilitates communications between separate DOS programs using DOS's
multiplex interrupt. Commonly, these will be memory-resident programs
addressed by an application running in the foreground.
|
Performance
|
- RTKernel offers remarkable performance and power. It comes with a
benchmark program that can be used to measure its performance on any
computer. The table below gives some results for three typical
computers:
- 33 MHz
80486
|
- 20 MHz
80386
|
- 12 Mhz
80286
|
- RTKernel Operation
|
- 6
|
- 27
|
- 58
|
- Round-Robin task switch
|
- 10
|
- 42
|
- 89
|
- Semaphore task switch
|
- 3
|
- 13
|
- 22
|
- Semaphore Signal
|
- 2
|
- 8
|
- 13
|
- Semaphore Wait
|
- 14
|
- 65
|
- 115
|
- Task activation (Signal, Wait)
|
- 7
|
- 20
|
- 35
|
- Store data in a mailbox
|
- 7
|
- 21
|
- 39
|
- Retrieve data from a mailbox
|
- 18
|
- 63
|
- 114
|
- Task-to-task communication
|
- 24
|
- 77
|
- 150
|
- Task-to-mailbox-to-task communication
|
-
All times are given in
microseconds
|
Programming Examples
|
- Here are two complete RTKernel programs in C and PASCAL with two
tasks each and a task activation using a semaphore:
-
#define MainPriority 3
TaskHandle HandleA;
Semaphore S;
void TaskA(void)
{
RTKWait(S);
}
void main(void) // Main-Task
{
RTKernelInit(MainPriority);
S = RTKCreateSemaphore(Counting, 0, "Demo-Sema");
HandleA = RTKCreateTask(TaskA, MainPriority+1, 1024, "Task-A");
RTKSignal(S);
}
-
PROGRAM RTKDemo;
USES
RTKernel;
VAR
HandleA: RTKernel.TaskHandle;
S : RTKernel.Semaphore;
PROCEDURE TaskA;
BEGIN
RTKernel.Wait(S)
END;
BEGIN { Main-Task }
RTKernel.InitSemaphore(S, Counting, 0, 'Demo-Sema');
RTKernel.CreateTask(TaskA, MainPriority+1, 1024, 'Task-A', HandleA);
RTKernel.Signal(S)
END.
|
System Requirements
|
Before a program using RTKernel can run, the following requirements must
be satisfied:
- The target computer must have at least 32K RAM available.
- The target computer must have an Intel 8086 compatible processor.
- The target computer must run under MS-DOS, version 3.0 or higher, or
without an operating system. To build an application to run without
DOS, the RTKernel Source Code is required.
RTKernel-C supports:
- Turbo/Borland C/C++ (Version TC++ 1.0 and higher)
- Microsoft C/C++ (Version 6.0 and higher)
- Real Mode, 16-bit Protected Mode, and 32-bit Protected Mode
(Protected Mode is only supported with Borland C/C++, version 4.02 and
higher with the Borland PowerPack, running under DOS)
RTKernel-Pascal supports:
- Turbo/Borland Pascal (Version 5.0 or higher)
- Real Mode and 16-bit Protected Mode
|
RTKernel Demo
|
The RTKernel Demo is available for download from the Demo Software
download page.
The RTKernel Demo contains the application program interface (API) of
RTKernel and all drivers delivered with RTKernel as C header files and
Pascal unit interfaces.
The Demo also contains four executable RTKernel programs. The complete
source code for these demo programs is also supplied, in both Pascal and C
versions. These programs serve to demonstrate how easy it is to use
RTKernel.
- RTDemo is the largest of the demo programs. It
consists of eight tasks and shows how several tasks can run in
parallel within a program without any restrictions. The files
RTDEMO.PAS and RTDEMO.C contain detailed information about the
program. RTDemo uses RTKernel's Debug Version and demonstrates, among
other features, the following:
- Parallel screen access of several tasks
- Parallel DOS calls of several tasks
- Parallel DOS programs (FORMAT.COM, COMMAND.COM, and RTDEMO.EXE)
being executed by different tasks
- Printing in the background
- Interrupt-driven keyboard input
- Interrupt-driven reception of data at a serial port
- Measurement and display of CPU load
- Modification of the timer interrupt rate
- Cyclic tasks (tasks running in a fixed time frame)
- Usage of CPU time by other tasks during disk-I/O idle times
- Kernel Tracer
- Program COMDemo demonstrates the processing of
serial port interrupts. It requires two computers connected by a
serial cable (a minimal configuration with leads Receive, Send, and
Ground connected is sufficient). After the program has been started on
both computers, arbitrary lines of text may be entered and then
transmitted to the other computer using the <RETURN>-key. Both
computers can independently and asynchronously transmit data to one
another.
- Program IPXDemo demonstrates the transmission of
data using a Novell network. To use it, at least two workstations in a
Novell LAN (e.g., Novell NetWare or Novell NetWare Lite) are required.
On the workstations, only Novell's IPX driver needs to be loaded.
Further information is given by the program when it is executed.
- RTPrimes implements a quite slow and
"memory-hungry" prime number generator. What's interesting
about it is the algorithm used: RTPrimes computes prime numbers by
running many tasks concurrently. The program creates - depending on
available memory - up to approximately 1000 tasks. RTPrimes also shows
how to use reentrant code (nearly all of the program's tasks execute
the same code).
In addition to the demo programs on the Demo Disk, nine more demo
programs and numerous examples in the User's Manual are delivered with
RTKernel.
|
Home
|