Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

C++ and pthreads

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.

7 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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

    -Michael
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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