![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Runtime System Overview In the following sections we present the structure of the Apex runtime system, an overview of the runtime system components, and some miscellaneous information. This discussion is applicable to all Apex products in general and to the self-hosted Rational Exec runtime in particular. See the runtime guides for other products for details specific to them. These guides are:
- Multithreaded Ada Guide (Self-host over threads, Embedded for LynxOS)
- Embedded Programming Guide for Rational Exec
- Embedded Programming Guide for Tornado
- Embedded Programming Guide for LynxOS
- Apex for Windows NT Runtime Guide (Self-host)
The following topics are covered in this section:
- Classification of Ada Runtime Systems
- The Apex Runtime Structure
- The Ada Tasking Layer
- The Ada Kernel Layer
- The Target Kernel Layer
- Ada I/O
- Debugging and the Runtime System
- Runtime System Interfaces
- Ada_Krn_Defs and Ada_Krn_I
Classification of Ada Runtime SystemsApex runtime systems can be classified by the hardware platform and operating system (OS) that they support. Within this classification, there are still several runtime systems optimized to support different sets of features, both Ada language features and Rational extensions and layered products.
The broadest classification of Apex products and the corresponding runtimes is based on the type of hardware platform supported. Apex embedded products run on a full function computer, the host, and create applications that run on generally smaller and more limited embedded computers, the target. Apex native products also run on full function hosts and generate applications that can be run on the host or a compatible computer. For native products, host and target are the same, so they are sometimes referred to as self-hosted products.
For native platforms, runtime systems are divided again based on the method used to support Ada Tasking features. Apex for Rational Exec implements multiple threads of control directly using the processor instruction set. Apex for POSIX threads uses the implementation of POSIX threads provided by the target OS for multithreading support, implementing each Ada task as a POSIX thread. Both runtime variants use OS services to implement other runtime services, such as support for signals and time. Apex for Windows NT is similar to Apex for POSIX threads except that the Windows NT API is targeted instead of POSIX.
For embedded platforms, runtime systems are also divided based on OS support. Apex Embedded for Rational Exec uses the same techniques and much of the same code that Apex for Rational Exec uses on native targets to implement Ada tasks. In addition, it implements all other runtime services, such as support for interrupts and time, directly over the hardware. Apex Embedded for Tornado implements runtime services over the VxWorks embedded operating system.
Apex Embedded for LynxOS is a special case. Its runtime is essentially that of Apex for POSIX threads, since it is a full implementation of POSIX with realtime and threads extensions, but it is an embedded product, since applications are built on Sun Solaris computers. For purposes of describing the runtime, it should be considered to be an Apex for POSIX threads product.
For a given hardware platform with given OS support there will be several runtimes optimized for different sets of runtime features. There are in general four levels of support for the Ada language: ts0, ts1, ts2, and ts3. These are provided in archive libraries starting with libada.ts?, where ? is one of 0, 1, 2, and 3. The Apex prelinker automatically chooses which of these libraries is appropriate for your application. The features supported by each library is a proper superset of those supported by the previous one:
ts0 Nontasking features (Rational Exec only)
ts1 Basic tasking support
ts2 Support for terminate alternatives
ts3 Support for all Ada features
On some platforms, additional runtime libraries may be provided to support Rational features such as application profiling.
The Apex Runtime StructureThe Apex runtime system has been designed to be fast and portable. Portability has been achieved by using a layered model for constructing the runtime system, with a Target Kernel as the innermost layer. Figure 1 shows the different layers of the runtime system.
Figure 1 Ada Runtime Layers
![]()
The layered design of the runtime has enabled us to move much of the Ada Tasking and rendezvous semantics to a level higher than the kernel, closer to the application. As a result, many of the common operations are handled without going into the Ada Kernel at all and the total throughput of the system is enhanced.
The Ada Tasking LayerThe Ada Tasking Layer is made up of the Ada Tasking and VADS Exec services. Both the interface to these services and their implementation are common to all implementations of Apex, although some of the extensions shown are part of optional products.
Note: The VADS Exec extensions are derived from and provided backward compatibility with the Verdix Ada Development System, one of the ancestors of Apex. The acronym VADS is used for historical purposes.
These services are directly available to the application program, and are implemented using the API provided by the Ada Kernel Interface, but are otherwise mostly independent.
The Ada Tasking services are different from the rest of the services in this layer because they are called implicitly by the code generated by the Apex compiler. In other words, although your Ada Tasking application calls Ada Tasking functions, the calls are not visible in your source code. You can see the calls if you disassemble certain parts of your program in the debugger. We strongly discourage you from putting calls to any of the routines in the Ada Tasking Interface into your source code.
The VADS Exec functions are documented in the Ada Runtime Services manual. The packages in the v_*.1.ada files in the rts_vads_exec.ss subsystem provide the user's interface to the following VADS Exec services:
- Signal Handling
- Mailboxes
- Memory Management
- Semaphores
- Tasking Extensions
- Stack Operations
- Named Objects
- Mutexes/Condition Variables
The Ada Kernel LayerThe Ada Kernel Layer provides services used to implement the Ada Tasking Layer. These are implemented in turn over the services provided by a Target Kernel Layer, which mediates between this layer and the hardware of the target computer. Like the Ada Tasking and VADS Exec Interfaces, Ada Kernel Layer services are common to all Apex implementations, but unlike them their implementation varies, since different Target Kernel Layer implementations provide different services to the Ada Kernel Layer. This layered model has enabled us to use different Target Kernels underneath the Apex runtime, yet still provide an identical set of services to the Ada application. The Ada Kernel Layer and the corresponding Target Kernel Layer together make up the Kernel Layer, a complete implementation of the Ada Kernel Layer over the target hardware.
We recommend that you do not call Ada Kernel services directly. These services are described mainly for completeness. There is one exception; there are some object attributes such as tasking attributes that the application can set to cause different behavior. The Ada Kernel Layer provides routines to initialize these attributes. These routines are supported on all Apex implementations, even though the underlying representation of the attributes may vary between Target Kernel Layers.
The Target Kernel LayerA Target Kernel Layer provides adequate control of the target computer hardware to support Ada Kernel services. Apart from this minimum requirement, Target Kernel Layers differ considerably, both in the exact services provided and the interfaces to those services. In general, a Target Kernel Layer must provide a means for executing a program, creating and synchronizing multiple threads of control within that program, provide asynchronous notification to the program (e.g. interrupts or signals), I/O to peripheral devices, and a time base.
We have implemented our own Target Kernel Layer, the Rational Exec Microkernel. All other Target Kernel Layers consist of OS support provided by other vendors. Since it was designed specifically to support the Ada Kernel Interface, applications using the Rational Exec Microkernel will generally be faster than those using other alternatives.
There are two variants of the microkernel: Rational Exec Microkernel for Embedded and Rational Exec Microkernel for POSIX. Both variants share the implementation of multithreaded support for Ada tasks but differ in the implementation of other runtime services (e.g. interrupt support, time). Rational Exec Microkernel for Embedded implements all services directly over the hardware; most of the hardware support can be configured by the end user to support different hardware or to improve support for existing hardware. Rational Exec Microkernel for POSIX implements these nontasking features using OS support accessed through the POSIX API, and is supported on all Apex native products except Apex for Windows NT.
On all Apex native products (except Apex for Windows NT) and Apex Embedded for LynxOS, a POSIX implementation is supported as a Target Kernel Layer. These runtimes implement each Ada task as a POSIX thread. POSIX is a standard API for OS services implemented by all Unix-based platforms supported by Apex. The POSIX threads extension is specifically designed to allow a multiprocessor implementation, so on computers with multiple processors POSIX threads may run simultaneously. Applications linked against a POSIX runtime may therefore run Ada tasks simultaneously on different processors. These runtimes also have the advantage of greater compatibility with foreign language code that uses POSIX threads.
Apex Embedded for Tornado uses VxWorks, a real-time OS from WindRiver Systems Inc. as its Target Kernel Layer. Here each Ada task is implemented as a VxWorks task. These runtimes have the advantage of using existing VxWorks configurations. This is especially valuable if there is no Rational Exec configuration for a particular embedded processor, since creating a new Rational Exec configuration can be time consuming.
Apex for Windows NT uses the API implemented by Windows NT from Microsoft Corporation as its Target Kernel Layer, implementing each Ada task as a Windows thread. This is the only option for creating Apex applications to run on Windows NT or the related Windows 2000.
Ada I/OThe implementation of the I/O packages specified in the LRM (e.g. Ada.Text_Io, Ada.Sequential_Io, Ada.Direct_Io) lies outside the layered structure of the tasking runtime services described above. These services are implemented directly over OS services. In the case of Apex Embedded for Rational Exec, where there is no OS, these services are implemented using traps to the Target Debug Monitor (TDM), which performs the I/O on the host.
Debugging and the Runtime SystemThe Apex debugger is aware of the tasking supported in the runtime system, regardless of the Target Kernel being used. All tasks in the program are displayed with appropriate status in the Tasks window of the debugger, or in response to the lt debugger command. In addition to listing the tasks, the debugger allows you to select each of the tasks and move up and down on the call stack of that task to examine current execution state, including the values of variables and registers. There are other commands specific to the Target Kernel being used that provide more platform specific information about tasks and the OS entities over which they are implemented.
A complete description of the Apex debugger can be found in the Using the Apex Debugger guide.
Runtime System InterfacesTable 1 shows the files in the Apex release that correspond to the interfaces shown in Figure 1 .
Ada_Krn_Defs and Ada_Krn_IWith the exception of the object attribute initialization routines in Ada_Krn_Defs, we recommend that you do not call this interface directly. This internal interface is documented to show how the Ada Kernel works.
In Ada Kernel Layer Implementation there is a list of mechanisms available to the application to control the attributes of the Ada kernel objects. The attribute initialization routines in Ada_Krn_Defs are provided for this purpose.
The interface is consolidated in one package, Ada_Krn_I. Most of the services are needed to support the Ada Tasking semantics. The remaining services are needed to support VADS Exec. The VADS Exec services are optional and not supported by all runtime variants.
The services are subdivided into the following groups.
- Ada Program
- Kernel Scheduling
- Task Management
- Task Masters Synchronization
- Task Synchronization
- Interrupts
- Time
- Allocation
- Mutex
- ISR Mutex
- Condition Variable
- Semaphore
- Count Semaphore
- Mailbox
- Callout
- Task Storage
- Name
- Protected Records
All type definitions used by the Ada Tasking layer that are Target Kernel specific are defined in the Ada_Krn_Defs. Package Ada_Krn_Defs also contains numerous functions for allocating and initializing object attribute records.
Ada_Krn_Defs contains type definitions for the following objects:
- mutex
- condition variable
- semaphore
- counting semaphore
- mailbox
Rational Software Corporation http://www.rational.com support@rational.com techpubs@rational.com Copyright © 1993-2002, Rational Software Corporation. All rights reserved. |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |