473,804 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C++ STL in embedded systems

Are there any restrictions/problems for use of C++ STL in development
in embedded systems?
In particular:
* Does STL require too much space/memory?
* Is 'implementation of STL algorithms/methods' reenterable/reentrant?
* What is the cost to provide continuity of vectors in memory?
Any other problems?

--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

Jan 3 '06
49 8978

Alex Vinokur wrote:
Are there any restrictions/problems for use of C++ STL in development
in embedded systems?

....

Here is a link to the slides for a 1999 presentation by Bjarne
Stroustrup about
using Standard C++ including the STL in embedded systems.

http://public.research.att.com/~bs/esc99.html

Jan 5 '06 #31
"Alex Vinokur" <al****@users.s ourceforge.net> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
P.J. Plauger wrote:
"Alex Vinokur" <al****@users.s ourceforge.net> wrote in message

[snip]
> Does 'Green Hills C++ Compiler' use your Abridged library?


Yes. They also ship our full C++ library as well.

[snip]

Is 'implementation of STL algorithms/methods in Extended Embedded C++'
reenterable/reentrant?


Yes.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jan 5 '06 #32
With regard to the number below:

Read, sort, and write floating-point numbers

unoptimized optimized

elements C++ C C/C++ ratio C++ C C/C++ ratio

500,000 3.5 6.1 1.74 2.5 5.1 2.04
5,000,000 38.4 172.6 4.49 27.4 126.6 4.62
One of things I find interesting about the source - he used is his
comment:

buf.reserve(res ); // logically redundant; for efficiency only

How is that 'logically redundant'. If you _dont_ call reserve. You'll
end up with a host of re-locations and the C++ numbers will be alot
worse. Am I missing something?

Jan 5 '06 #33

ma740988 wrote:
With regard to the number below:

Read, sort, and write floating-point numbers

unoptimized optimized

elements C++ C C/C++ ratio C++ C C/C++ ratio

500,000 3.5 6.1 1.74 2.5 5.1 2.04
5,000,000 38.4 172.6 4.49 27.4 126.6 4.62
One of things I find interesting about the source - he used is his
comment:

buf.reserve(res ); // logically redundant; for efficiency only

How is that 'logically redundant'. If you _dont_ call reserve. You'll
end up with a host of re-locations and the C++ numbers will be alot
worse. Am I missing something?


std::vector::re serve() only functions to speed things up; it doesn't
have an effect on the result of the program. Likewise, I might do this:

void Increment1( int& i )
{
const volatile n = 10;
i += n;
i -= (n-1);
}

void Increment2( int& i )
{
++i;
}

These two are logically equivalent (i.e., they do the same thing), but
the second is almost certainly more efficient.

Cheers! --M

Jan 5 '06 #34
mlimber wrote:
void Increment1( int& i )
{
const volatile n = 10;


Oops. That should have an "int" thrown in there.

Jan 5 '06 #35
|| std::vector::re serve() only functions to speed things up; it doesn't

|| have an effect on the result of the program.
There to speed things up but doesn't affect the result of the program!!
Not just bear with me. You're saying that if I opt not use reserve
the end result (i.e the benchmarks) would be the same?

're-location' is a constant 'concern/gripe' when viewed from - what
seemingly is the most popular container. i.e the Vector. INMHO, it's
a much ado about nothing if you have a member function like reserve.
That said, if you opt _not_ to reserve, you're faced with the
copy/destroy/re-create saga. With your example 'benchmarks' will be -
for the most part - comparable. I'm not seeing how the benchmarks will
be comparable if he chose to call reserve ahead of time.

Time to pull out the compiler :)

Jan 5 '06 #36
ma740988 wrote:
|| std::vector::re serve() only functions to speed things up; it doesn't
|| have an effect on the result of the program.

There to speed things up but doesn't affect the result of the program!!
Not just bear with me. You're saying that if I opt not use reserve
the end result (i.e the benchmarks) would be the same? [snip]

No, I'm saying the sorted output of the program would be identical.From a logical point of view, speed doesn't matter. Likewise,

Increment1() and Increment2() are identical in function (i.e. logically
the same) but different in implementation, which translates to speed of
execution for our current context.

Cheers! --M

Jan 5 '06 #37
AD
I did face few issues when introducing STL in a vxWorks based
system.Major problems were:
- significant code bloat
- incomplete STL support by the specific vxWorks version that we were
using. There were scores of linking errors whenSTL was used.Had to make
modifications to the STL header files to make it work.
- no concept of namespace on vxWorks (Everything happened to be in
default namespace)

But probably these issues are specific to vxWorks (and that too to a
particular version of it) and may not hold true for embedded system in
general. But Code bloat was definitely a problem and I found many
resources on Net which confirmed this problem of using STL in embedded
systems.

Jan 5 '06 #38
|| But probably these issues are specific to vxWorks
|| (and that too to a particular version of it) and may not hold
|| true for embedded system in general

How long ago was this? I'm using vxWorks (Tornado IDE 2.2.1) - STL
and all. Doing FFT/IFFTs and Boundary Element Math withough a hitch.

|| But Code bloat was definitely a problem and I found many
|| resources on Net which confirmed this problem of using STL in
embedded
|| systems.
Is this relegated to 'embedded systems'? Furthermore, how do you
measure this 'code bloat'? I'm curious.

With all due respect. I think today (my experience) - this notion of
issues pertaining to STL usage in embedded systems is much ado about
nothing (lots of smoke and mirrors). My _real_ problem, is being stuck
with gcc 2.96. Beyond that. I've had no issues. Of course I haven't
measured code bloat yet but we'll see.

Jan 5 '06 #39
Alex Vinokur wrote:
Are there any restrictions/problems for use of C++ STL in development
in embedded systems?

[snip]

In general, you can't give a simple answer to such questions.
The specifics of how your particular embedded system works
are going to, in the extreme cases for various features, be the
choke point.

Consider a case where, for hardware reasons, you needed to
limit the amount of RAM on your system to the absolute
smallest possible amount. Anything that produced an extra
temp variable, an extra chunk of something shoved on the
stack, etc. etc., would be hard to accomodate. In such a case,
it might be easier to get your job done in some other language
than C++. Possibly assembler, for example. Though as time
goes by, the amount of RAM available on most hardware is
increasing. I recall a project from many years ago where
an industrial monitor (radiation hand and foot checker) had
a very small amount of RAM, like 128 bytes or some silly
small number. Trying to fit a C++ prog into such hardware
would have been tiresome. RAM is much cheaper these days.
The latest version of this device has a huge whack of RAM.

Other considerations: Suppose the system cannot require
human intervention, or human intervention is expensive in
some way. In such a case, a "bullet proof" implementation
that won't crash, won't leak resources, etc., is going to be
a big concern. A good implementation of the STL will look
pretty good in such cases, as compared to a roll-your-own
set of containers. So will reading the series of books
"Effective C++", "More Effective C++", and "Effective STL"
(though I may have munged the titles).

There are many other possible concerns. For example:
You need a compiler that outputs optimized code for
your hardware. This is crucial above all else. If the code
won't run on your hardware, there's no point worrying
about what library to use. So, if your compiler has limits
(not unusual in the case of hardware specific compilers,
though getting better) you should start with your list of
possible compilers, and figure out what is possible from
that. If the only compiler available is an older non-compliant
one, you may have trouble getting a good STL implementation
to work on it. I recall another project from many years ago
where the only compiler that would output code for the
hardware was a C compiler. And an old (1988 or so) C compiler
at that. Tiresome.

What other libraries are required for the project? If it's
a specific chunk of hardware, chances are there is an
API kit provided by the manufacturer. The advantages of
using such a kit may outweigh the advantages of using
the STL, supposing you can't use both. Though, again,
as time goes by most hardware makers are supporting
the STL, and more modern implementations of it.

There are many other possible considerations. For
example, if you explore these issues, the client might
be convinced that the extra RAM might be worth it in
order to be able to shorten the development time. Or
to be able to do the development in C++ rather than
assembler, and so be able to provide lots of new
sexy features in the same development time.
Socks

Jan 5 '06 #40

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
3105
by: Brandon | last post by:
Java seems to have taken off as the platform and language of choice for many embedded devices. Would it be feasible for Python(perhaps running on an embedded version of Linux) to act in such a capacity. Most of my experience with Python has been with Unix-type scripting tasks and using it when it is an applications built in scripting, but I know some people try to use to build larger complex applications. Is the Python interpreter portable...
12
2985
by: Bill Hanna | last post by:
C is inadequate for embedded systems for the following reasons: 1) Direct addressing of memory mapped I/O is not supported simply and easily. You have to find work-arounds that are compiler dependent. You have to create macros , use casting and use indirect addressing (pointers) to read or write to memory mapped I/O. 2) C does not support real time interrupts. The interrupt vectoring is compiler dependent.
10
2523
by: Alex Vinokur | last post by:
The memory allocation issue in embedded systems is usually critical.. How can one manage that? 1. Via 'new' char* p = new (nothrow) char ; if (p == 0) { // He we know that it is impossible to allocate the requested memory // We can do something relevant.
20
22550
by: Jack | last post by:
Is there a Python packaging that is specifically for embedded systems? ie, very small and configurable so the user gets to select what modules to install? For Linux-based embedded systems in particular? I'm thinking of running it on the Linksys's Linux-based open source router WRT54G. It has 4MB flash and 16MB RAM. I think another model has 16MB flash. Any possibilities of running Python on these systems?
0
2273
by: YellowFin Announcements | last post by:
Whitepaper: "Yellowfin Reporting" enables Embedded Business Intelligence -------------------------------------------------------------------------------- Embedded reports are a standard requirement of most applications. But users are increasingly demanding more sophisticated reporting from applications - seeking such features as custom report design, ad hoc report creation and analytics. Developers that want to embed business...
2
1313
by: pdeivanayagam | last post by:
hi i hav cmpltd my engg.i am thnkng of doing an embedded systems. course...can i knw abt prospect of embedded systems?wut will be the oppurtunities available in embedded systems?i want some infm reg this.can anyone guide me reg this? regards deivanayagam
14
1900
by: Martin Wells | last post by:
When I want to store a number, I use "unsigned". I go with unsigned because it's the natural type for the system, and so should be the fastest. However, there are 8-Bit microcontrollers out there that do 8-Bit arithmetic faster than 16-Bit arithmetic, and so on these systems char is faster than int. Standarising C in such a way that int is at least 16-Bit, has this made C both slow and memory-hungry for embedded systems programming?
20
2056
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
There are a few guarantees I exploit in the C Standard. For instance, I might write (unsigned)-1 to get the maximum value for an unsigned integer. Also, I might rely on things such as: memset(data,-1,sizeof data)
30
4308
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
Let's say we had a simple function for returning the amount of days in a month: unsigned DaysInMonth(unsigned const month) { switch (month) { case 8: case 3: case 5:
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9593
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7633
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.