Implementation Aspects
general design principles followed when designing the architecture
for the AOCS Framework are discussed under the following headings:
Implementation Language
The framework prototype was implemented in C++ but its design can in general
be implemented on any object oriented language that supports multiple implementation
of abstract interfaces (see also language
compatibility).
In order to ensure compatibility with the real-time environment in which
the framework is expected to be used, only a subset of the C++ features
were used. More specifically, the following features were not used:
-
exception handling
-
multiple inheritance of implementation (see also discussion
on MI)
-
run-time type information
-
unsafe type casting (except in wrappers that are specifically designed
to safely handle this type of casting)
-
operator overloading
Memory is allocated only during the initialization phase. No dynamic memory
allocation is performed during normal operation (ie. no calls to the new()
operators are made during normal operation).
In order to eliminate the danger of "dangling pointers", complex objects
(ie objects that are directly or indirectly derived from class AocsObject)
are never destroyed until application termination. This restriction also
applies to object destruction on the stack. One implication is therefore
that such objects are never passed by value in method calls. Only pointers
to objects are passed as method parameters, never the object themselves.
This guarantees that references to objects remain always valid.
Compliance with the rules forbidding dynamical destruction of complex
objects is ensured by having the destructor of class AocsObject
raise a failure event if it is ever executed. In a more radical approach,
one could make the destructor private which would ensure that
the compiler detects any attempt to destroy an object dynamically. This
was not done in the framework prototype because of interference with the
testing programs.
Back to Top, Back
to Aocs Framework Project Home
Use of Parasoft's Code Wizard
The C++ language is notoriously dangerous if not used carefully. The previous
section outlined some guidelines that were enforced during the development
of the framework prototype to avoid common C++ pitfalls. In the AOCS Framework
Project, compliance with these guidelines was initially verified manually.
Towards the end of the project, the CodeWizard tool from Parasoft
was procured and evaluated. CodeWizard essentially extends the C++ compiler
to enforce safe coding practices. It has a large set of built-in rules
and additionally allows users to define their own project-specific rules
using a very simple graphical interface. The latter feature is especially
valuable in the context of the AOCS Framework as it would allow compliance
with the rules mentioned in the previous
section to be verified automatically. The experience with CodeWizard
was very positive and CodeWizard is regarded as the kind of tool that can
bring C++ to the same, or even higher, standards of safety and reliability
as exhibited by languages like Ada.
Back to Top, Back
to Aocs Framework Project Home
Framework Overheads
Use of a framework approach introduces two types of overheads with respect
to an object-based
implementation:
-
overheads due to dynamic binding
-
framework-specific overheads
The overheads due to dynamic binding are common to all object-oriented
applications. Their impact can be summarized as follows:
-
Dynamic binding introduces an additional layer of indirection and therefore
slows down application execution. The overhead in a call to a dynamically
bound method with respect to a call to the same method when it is statically
bound is roughly equivalent to the overhead of having one extra parameter
in the method call. The only study to have tried to quantify this type
of overhead seems to be K. Driesel in: The Direct Cost of Virtual Function
Calls in C++ (ACM Sigplan Notices, Vol. 31, n. 10, Oct. 1996) that
puts its average value at about 5%.
-
Dynamic binding also has an impact on memory usage which consists in a
virtual function table to be created for every class that declares virtual
methods, and a pointer to the virtual function table to be added to every
instance of such classes. See D. Herity, C++ In Embedded Systems: Myth
and Reality (Embedded Systems Magazine, Feb. 1998) for a technical
discussion.
The framework-specific overheads represent the price that is paid for having
a reusable architecture. They arise from the structure of the framework
as a domain-specific
extension of the operating system. The framework-specific overheads
can be measured in the same manner in which OS overheads are usually measured.
The memory overhead is simply given by the memory occupied by the functionality
managers which represents the ballast that the framework introduces at
application level. With the configuration
used for the AOCS framework prototype this is equal to just over 60
kBytes (including both code and data). Since a typical AOCS application
might occupy around 400-600 Kbytes, the framework memory overhead is around
10-15%.
CPU overheads can be established by measuring CPU usage when the functionality
managers run “empty” (ie. no components plugged into them). In the AOCS
framework prototype, an empty cycle takes 0.2 ms with the SPARC processor
running at 14 MHz. Since typical AOCS cycles last 100 ms or more, the framework-induced
CPU overhead is nearly negligible.
Back to Top, Back
to Aocs Framework Project Home
Testing Configuration
The configuration used for testing the framework prototype was the ERC32
SPARC processor with the RTEMS
operating system. The ERC32
cross-compilation system (version 2.0.7) based on the GNU compiler
was used as a development environment. The tests were performed on
the ERC32
simulator (version sis-3.0.5) that simulates the operation of the hardware
to bit level and exactly reproduces its timing behaviour.
Back to Top, Back
to Aocs Framework Project Home
Last updated on Feb. 5-th 2002 by Alessandro
Pasetti