This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFC - multithreaded exceptions support for single CPU embedded systems
- From: Øyvind Harboe <oyvind dot harboe at zylin dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 16 Jul 2003 10:29:16 +0200
- Subject: RFC - multithreaded exceptions support for single CPU embedded systems
I'm not terribly familiar with exceptions, but I've made some
very simple modifications to eCos and GCC code to add support
for multithreaded exceptions. I needed this for development
purposes and it seems to work quite well.
Q: is this a sound method for adding multithreaded support to
deeply embedded targets?
Øyvind
Index: unwind-sjlj.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/unwind-sjlj.c,v
retrieving revision 1.14
diff -u -r1.14 unwind-sjlj.c
--- unwind-sjlj.c 7 May 2003 22:11:34 -0000 1.14
+++ unwind-sjlj.c 16 Jul 2003 08:26:20 -0000
@@ -86,8 +86,25 @@
/* Manage the chain of registered function contexts. */
-/* Single threaded fallback chain. */
-static struct SjLj_Function_Context *fc_static;
+/* Single threaded(or multithreaded single cpu) fallback
+ * chain.
+ *
+ * Notice that this is a globally visible variable.
+ *
+ * The way the single threaded callback chain is extended to a
multithreaded
+ * callback chain, is that the scheduler during a thread switch saves
+ * the value of this variable in the thread state/structure for the
thread
+ * being switched out, and it restores the value from the thread being
+ * switched in.
+ *
+ * Thread startup routines are modified to initialize this value per
thread.
+ *
+ * This scheme only works for single CPU systems, but it is an
efficient
+ * and simple method method to add multithreaded
+ * exceptions to e.g. sources.redhat.com/eCos.
+ *
+ */
+struct SjLj_Function_Context *fc_static;
#if __GTHREADS
static __gthread_key_t fc_key;