Journal Articles
Browse in : |
All
> Journals
> CVu
> 113
(22)
All > Topics > Design (236) Any of these categories - All of these categories |
Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.
Title: Impression of C++ for Embedded Systems
Author: Administrator
Date: 03 April 1999 13:15:30 +01:00 or Sat, 03 April 1999 13:15:30 +01:00
Summary:
Body:
If you think about C++ you think about probably think about programming a PC, a MAC, a RS/6000 etc. but not an embedded system. The effort for embedded systems is very high. It is not possible to port a complex application that is written in C++ to an embedded system without any changes. Of course the frontend doesn't really change. What changes is the backend. The code that is produced by the backend for an embedded system is named embedded code. Such a kind of code runs e.g. on any kind of front panel. Today it is very important to think about the possibility of programming embedded systems in C++ because the applications for them are ever increasing in size and become ever more complicated.
In earlier days you could distinguish between low-level and high-level systems. Today the lines between these have blurred very much. To program embedded systems special languages are available which support the underlying embedded system. Each language has its own special features. In some cases a language with special features is available for a special embedded system. If you read design papers of C++ for embedded systems you will find out two very important points: The first is that the language standard is snipped e.g. currently templates cannot be used or some features are not completely available e.g. simple inheritance instead of multiple.
It depends on the efforts of the application if it makes sense to use such compilers. In the most cases you program embedded systems in C (or in assembly). One of the biggest problems is how to handle the memory. Most C++ compilers for embedded systems only support non-dynamic memory handling. On embedded systems garbage collection is often necessary also the distribution of code. The problem is that neither of these language items is fixed in the standard of C++.
Of course in some compilers they are implemented but not in a very clear way. At this point it is important not to misunderstand the sense of C++. C++ is a programming language and not a workbench. That is the reason why it is necessary that you find a way to use the complete language on an embedded system and not only a few parts of it. The consequence is that C++ needs variable backends which port C++ e.g. to C. The next step is that the C compiler produces the optimised embedded code. Most C++ compilers which produce assembly code in a direct way do that very ineffectively. The assembler code that is produced out of the same program, first compiled by a C compiler and second by a C++, differs in markedly. The code of the C compiler is much more compact than that produced by the C++ program. You can try it out by writing a simple "hello-world" program and compile it with a C and than with the C++ compiler by using the -S option.
I know that this comparison is not really right but I hope you know what I mean. Because of this fact it is much more important to build, as mentioned above, variable backends for C++. In addition I am sure that Java becomes more and more important for embedded systems because for the writing of GUIs. Such GUIs can be used on an embedded system and on different kinds of computers on which a JVM is available without changing the code. Because of this fact a JVM must be available on the intended embedded system. In the most cases this is not so. The consequence is to port the Java code to C. The same is true for C++. The performance of a C++ compiler backend is too poor. I think it is not enough to use e.g. Java to C compilers for embedded systems but also C++ to Java compilers to use the power of C++ in Java programs. But that's not the point of this article.
C++ can be used for embedded systems for several reasons. The most important reason is that the design of software is done by using object-oriented methods like the UML. So it is very comfortable and would be easy if you could also use an object-oriented language to realise the design in a language. The software that is needed today for embedded systems becomes more and more complex so it is necessary to use C++ to get a short development cycle. Especially for user interfaces, C++ represents the most popular solution to program such ones.
The problem is how to handle C++ in an effective way. Before starting with the programming in C++ on an embedded system it is necessary that you do a very good design covering all main items of the problem you want to solve.
Especially the performance of a C++ program must be examined very carefully. It is not efficient to solve a program in an object-oriented way if the performance is low. Finally you have to find out about the technological side of using C++. Does the embedded system have enough resources to handle C++ programs and do you have all necessary tools. To program an embedded system in C++ differs greatly from programming a Pentium processor.
A very special point is the memory handling. You have to make sure that the used compiler can handle dynamic memory. Another point is the overhead of some language features.
Templates have a very big overhead. By using templates the performance of the application goes down. To solve this problem it is necessary that the selected compiler uses an optimisation mechanism that reduces the overhead of several language parts like templates.
Generally you have to find an optimisation strategy like the "inline" construct which kills the overhead of small functions. "inline" does not work very well on big functions, only on small ones.
Today an often used way is to migrate C code to C++ code. This way is very difficult and not very safe. To do so it is necessary and useful to examine the advantages and the disadvantages to do such a work. I will try to explain my experiences about that theme in one of the next "Overloads".
Those with an interest in embedded C++ should contact Henrik. I wish my German was as good as his English (I had to do fairly little editing to the above, yes I know it could have been further polished)
Notes:
More fields may be available via dynamicdata ..