This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Lightweight C++ multithreaded exceptions
- From: Øyvind Harboe <oyvind dot harboe at zylin dot com>
- To: ecos-discuss at sources dot redhat dot com
- Date: Sat, 21 May 2005 10:30:16 +0200
- Subject: [ECOS] Lightweight C++ multithreaded exceptions
One approach to supporting multithreaded exceptions that seem to work
quite well in my experience is to use the single threaded GCC toolchain,
but to make the the global variable in C++ exceptions, fc_static, per
thread. By 'per thread' I mean that just like a generic CPU register,
this global resource is part of the thread state.
The easiest way of doing this that came to mind, was to add code to the
eCos thread switching to save/restore the global variable on each thread
switch. This requires reusing a field in the thread class or adding a
new one. It was also suggested to make this support configureable via
CDL as it adds a *very* slight overhead to thread switching.
http://sources.redhat.com/ml/ecos-patches/2003-11/msg00047.html
However, it requires a patch to GCC to make fc_static visible (it is
currently declared static), which requires either get/set fn's or
changing the name to avoid polluting the global namespace, e.g.
_fc_static should do.
Advantages:
- very easy to do. 2 lines of code, 30 lines of fluff(#if'defs', etc.)
50 lines of documentation :-)
- GCC patch is simply changing:
static void *fc_static;
=>
void *_fc_static;
- no need to distinguish between single threaded or multithreaded
toolchains
- no need for multilib
- very efficient implementation
- no need for pthreads
- trivial change to eCos
- should work for all forseeable future
Disadvantages:
- requires a patch to GCC.
--
Ø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