Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

C++ and pthreads

Altera_Forum
Honored Contributor II
1,702 Views

Has anyone been able to get a program written in C++ (using STL) and using pthreads to run succesfully on uClinux? 

 

Depending on which toolchain I use, I can get one or the other to work, but not both.
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
861 Views

He have successfully developed a large application which uses STL extensively, especially container templates. 

 

However, we weren't able to compile even the simplest application with C++ and pthreads combined. If I recall correctly, we could make a sample application run, but when we used strings, vectors, or any interesting stuff, the test program would halt. 

 

Cheers, 

 

Ricardo.
0 Kudos
Altera_Forum
Honored Contributor II
861 Views

In a no-MMU environment "__thread" variables are not available, this might prevent c++ in a threaded application. 

 

In an MMU enabled environment atomic operations are not (yet) functional. This will result in a memory manager work either slow (using OS based locks) or not correctly (when trying to use the not yet implemented atomic functions).  

 

-Michael
0 Kudos
Altera_Forum
Honored Contributor II
861 Views

Its weird that if I compile a C program with pthreads, it works fine. But if I compile a C++ program with pthreads, it hangs at the first pthread_create call. I'm pretty fuzzy on the low level details, but why would there be a difference there? 

 

Thanks
0 Kudos
Altera_Forum
Honored Contributor II
861 Views

Do you have any restrictions on using the MMU Linux distribution? (http://www.nioswiki.com/linux

 

It seems like it should be more capable of handling this kind of task correctly. Unfortunately, we are just starting experimenting with it, so I don't have much useful advise. 

 

Good luck, 

 

Ricardo.
0 Kudos
Altera_Forum
Honored Contributor II
861 Views

Well, the card we are using doesn't have an MMU, so that probably won't work for me. Thanks for the advice though.

0 Kudos
Altera_Forum
Honored Contributor II
861 Views

Maybe you should upgrade your NIOS to an MMU enabled version... 

 

-Michael
0 Kudos
Altera_Forum
Honored Contributor II
861 Views

Hi I'd like to ask similar question on pthreads and C++. 

 

I managed to compiled my application that uses pthreads using nios2-linux-uclibc-g++. So my question is whether it is best for me to run my application in nios2 with MMU or no MMU, in order to get thread atomicity etc? 

 

Thank you. 

 

Chiang
0 Kudos
Reply