This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

pthreads initialisation & C++ exceptions


eCos uses C++ constructurs in global variables to initialize the various
parts of the system.

For those that deem C++ legitimate in embedded applications, it is not
unreasonable to use C++ in setting up some hardware(e.g. FPGA
w/soft-UART) before the IO subsystem is up and running.

Problem: if a C++ constructor for a global variable uses exceptions
*before* the POSIX threads have been set up, then C++ pthreads
exceptions are initialized incorrectly. 

The nasty part is that initialisation is broken even if no exception is
actually thrown, it sufficies that _Unwind_SjLj_Register is invoked.

I'm not entirely comfortable by simply declaring this behaviour
"industry standard" :-)

Comments?

Here is the first thing that came to mind:

- Modify eCos pthreads to allow pthread_once() & pthread_key_create()
  to be invoked much earlier.
- Allow pthread_setspecific() & pthread_getspecific() to work outside
  a pthread, e.g. by using a single global variable when
  pthread_self_info() returns NULL.


I've compiled a CygWin hosted GCC 3.4.3 for ARM w/pthreads C++
exceptions & libstdc++. The binaries are available here if anyone is
interested:

http://www.zylin.com/gcc-arm-cygwin-3.4.3.zip

These are my crude working notes on how to build the toolchain:

http://www.zylin.com/howto_arm_gcc.txt



-- 
Øyvind Harboe
http://www.zylin.com


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]