RTS Programming Language
RTS Programming Language
RTS Programming Language
• Moreover, other additions to the language strived to make Ada 95 fully object -oriented. These included:
• Tagged types
• Packages
• Protected units
• Proper use of these constructs allows for the construction of objects that exhibit the four characteristics of object - oriented languages.
• In October 2001, a Technical Corrigendum to the Ada 95 Standard was announced by ISO/IEC, and a major Amendment to the international standard was published in March
2007. This latest version of Ada is called “ Ada 2005. ” The differences between Ada 95 and Ada 2005 are not extensive — in any case, includes a few changes that are of
particular interest to the real - time systems community, such as:
• The real - time systems Annex contains additional dispatching policies, support for timing events, and support for control of CPU - time utilization.
• The object - oriented model was improved to provide multiple inheritance.
• The overall reliability of the language was enhanced by numerous improvements.
C
• The C programming language, invented around 1972 at Bell Laboratories, is a good language for “ low - level ”
programming.
• The C language provides special variable types, such as register , volatile, static , and constant , which allow for
effective control of code generation at the procedural language level.
• When variable used as a register type, the compiler to place such a declared variable in a work register, which often
results in faster and smaller programs.
• Furthermore, C supports call - by – value only, but call - by - reference can be implemented easily by passing a
pointer to anything as a value.
• Variables declared as type volatile are not optimized by the compiler at all. This feature is necessary in handling
memory – mapped I/O and other special instances where the code should not be optimized.
• Automatic coercion refers to the implicit casting of data types that sometimes occurs in C.
• The C language provides for exception handling through the use of signals, and two other mechanisms, setjmp and
longjmp , are provided to allow a procedure to return quickly from a deep level of nesting — a particularly useful
feature in procedures requiring an abort.
• Overall, the C language is particularly good for embedded programming, because it provides for structure and
flexibility without complex language restrictions.
C ++
• C ++ is a hybrid object - oriented programming language that was originally implemented as a macro extension of C in the 1980s.
• Today, C ++ stands as an individual compiled language & exhibits all characteristics of an object - oriented language and promotes better
software - engineering practice through encapsulation and more advanced abstraction mechanisms than C.
• C ++ compilers implement a preprocessing stage that basically performs an intelligent search - and - replace on identifiers that have been
declared using the #define or #typedef directives.
• The problem with the preprocessor approach is that it provides a way for programmers to inadvertently add unnecessary complexity to a
program also it has weak type checking and validation.
• Previously C ++ programmers used complex pointer arithmetic to create and maintain dynamic data structures, cconsequently lots of
bugs appear. Today, however, standard libraries of dynamic data structures are available.
• There are three complex data types in C ++ : classes, structures, and unions. However, C ++ has no built - in support for text strings.
• Multiple inheritance is a helpful feature of C ++ that allows a class to be derived from multiple parent classes also complicated to
implement from the compiler perspective.
• C ++ still allows for low - level control; for instance, it can use inline methods rather than a runtime call.
• Furthermore, C ++ does not provide automatic garbage collection, which means dynamic memory must be managed manually or garbage
collection must be homegrown.
• Therefore, when converting a C program to C ++ , a complete redesign is required to fully capture all of the advantages of an object -
oriented design while minimizing the runtime disadvantages.
C#
• C# (pronounced “ C sharp ” ) is a C ++ - like language that, along with its operating environment, has similarities to Java and the Java
virtual machine, respectively.
• C# is first compiled into an intermediate language, which is then used to generate a native image at runtime.
• C# is associated with Microsoft’s .NET framework for scaled - down operating systems is highly configurable, capable of scaling from
small, and upwards (e.g., for real - time systems requiring user - interface support).
• The minimum kernel configuration provides basic networking support, thread management, dynamic link library support, and virtual
memory management.
• C# supports “ unsafe code, ” allowing pointers to refer to specific memory locations. Objects referenced by pointers must be explicitly “
pinned, ” disallowing the garbage collector from altering their location in memory. This capability could increase schedulability, and it
also allows for direct memory access ( DMA ) to write to specific memory locations;
• Moreover, C# provides many thread synchronization mechanisms, but none with this level of precision.
• C# supports an array of thread - synchronization constructs: lock, monitor, mutex, and interlock. A Lock is semantically identical to a
critical section — a code segment guaranteeing entry into itself by only one thread at a time like mutex .
• Finally, interlock, a set of overloaded static methods, is used to increment and decrement numeric in a thread - safe manner in order to
implement the priority - inheritance protocol. Timers that are similar in functionality to the widely used in C#. The accuracy of these
timers is machine dependent, and thus not guaranteed, reducing their usefulness in real - time systems to be used in multiple hardware
platforms.
• C# and the .NET platform are not appropriate for the majority of hard real -time systems for several reasons, including the unbounded
execution of its garbage - collection environment and its lack of threading constructs to adequately support schedulability and
determinism.
• C# ’ s ability to interact effectively with operating - system APIs, shield developers from complex memory management logic, together
with C# ’ s good floating – point performance, make it a programming language that is highly potential for soft and even firm real - time
Java
• Java, in the same way as C#, is an interpreted language, that is, the code compiles into machine - independent intermediate code that runs in a managed execution
environment.
• The obvious advantage is that Java code can run on any device that implements the virtual machine.
• However, there are also native - code Java compilers, which allow Java to run directly “ on the bare metal, ” that is, the compilers convert Java to assembly code or object
code.
• Furthermore, there are even special Java microprocessors, which directly execute Java byte code in hardware .
• Java is an object - oriented language and the code appears very similar to C++. Java supports call - by - value. But Java is a pure object - oriented language, that is, all
functionality in Java has to be implemented by creating object classes, instantiating objects of those classes and manipulating objects ’ attributes through methods.
• Of course, a good object - oriented design is not guaranteed, but the design obtained in the conversion will be a true object - oriented one based on the rules of the language.
This situation is quite different from the kind of false object - oriented conversion that can be obtained from C to C ++ in the blunt manner previously highlighted.
• Java does provide a preprocessor but constant data members are used in place of the #define directive, and class definitions are used in lieu of the #typedef directive.
• The Java language does not support pointers, but it provides similar functionality via references. Java passes all arrays and objects by reference, which prevents common
errors due to pointer mismanagement.
• Java only implements one complex data type: classes. Java programmers use classes when the functionality of structures and unions is desired. This consistency comes at the
cost of increased execution time over simple data structures.
• The Java language does not support standalone functions. Instead, Java requires programmers to bundle all routines into class methods again with significant cost. Moreover,
Java has no direct support for multiple inheritance however, allow for implementation of multiple inheritance.
• In Java, strings are implemented as first - class objects meaning that they are at the core of the Java language. Java ’ s implementation of strings as objects provides several
advantages. First, string creation and access is consistent across all systems. Next, because the Java string classes are defi ned as part of the Java language strings function
predictably every time. Finally, the Java string classes perform extensive runtime checking, which helps eliminate errors. But all these operations increase execution time.
• Operator overloading is not supported in Java. However, in Java’s string class, “ + ” represents concatenation of strings, as well as numeric addition.
• The Java language does not support automatic coercions. In Java, if a coercion will result in a loss of data, then it is necessary to explicitly cast the data element to the new
type.
Real - Time Java
• The specification must include a framework for the lookup and discoveryof available profiles.
• Any garbage collection that is provided shall have a bounded preemption latency.
• The specification must defi ne the relationships among real - time Java threads at the same level of detail as is currently available in existingstandards
documents.
• The specification must include APIs to allow communication and synchronization between Java and non - Java tasks.
• The specification must include handling of both internal and external asynchronous events.
• The specification must include some form of asynchronous thread termination.
• The core must provide mechanisms for enforcing mutual exclusion without blocking.
• The specification must provide a mechanism to allow code to query whether it is running under a real - time Java thread or a nonreal - time Java thread.
• The specification must defi ne the relationships that exist between real -time Java and nonreal - time Java threads.
• The RTSJ defines the real - time thread class to create threads which can access objects on the heap and d therefore can incur delays because of garbage
collection.
• For garbage collection, the RTSJ extends the memory model to support memory management which ensures no interfere with the real - time code’
stability to provide deterministic behaviour.
• RTSJ uses “ priority ” somewhat more loosely than is traditionally accepted. “ Highest priority thread ” merely indicates the most eligible thread — the
thread that the scheduler would choose from among all threads ready to run.
COMPILER OPTIMIZATIONS OF CODE
• There exist infinitely many object codes that implement the same computations produce the same
outputs when presented with the same inputs.
• Some of these object codes may be faster while others may require less memory. Hence, it is more
important use an optimized code.
• When beginning to use a new compiler, it is important to expose the details of the compiler for
effective optimized code design as well as one should know both the language and your compiler
thoroughly.
• Moreover, many of the techniques used in code optimization underscore, but the fact that
mathematical technique is that reformulate any algorithm or expression to eliminate time -
consuming function calls to improve real - time performance.
• Most of the code optimization techniques used by compilers can be exploited to reduce response
times. Often these strategies are employed invisibly by the compiler, or can be turned on or off
with compiler directives or switches.
COMPILER OPTIMIZATIONS OF CODE (contd.)
• Use of arithmetic identities and intrinsic functions
• Reduction in strength
• Common subexpression elimination
• Constant folding
• Loop invariant removal & induction elimination
• Use of registers and caches
• Dead - code removal
• Flow - of - control optimization
• Constant propagation
• Dead store elimination & variable elimination
• Short - circuit Boolean code
• Loop unrolling & jamming
• Cross - branch elimination