public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Øyvind Harboe" <oyvind.harboe@zylin.com>
To: ecos-discuss@sources.redhat.com
Subject: [ECOS] Lightweight C++ multithreaded exceptions
Date: Mon, 23 May 2005 09:13:00 -0000	[thread overview]
Message-ID: <1116664216.28556.45.camel@localhost.localdomain> (raw)

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

             reply	other threads:[~2005-05-21  8:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-23  9:13 Øyvind Harboe [this message]
2005-05-23 12:52 ` Jerome Souquieres
2005-05-23 13:25   ` Øyvind Harboe
2005-05-24  8:48     ` Jonathan Larmour
2005-05-24  9:01       ` Øyvind Harboe
2005-05-24  9:13       ` Paul D. DeRocco

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1116664216.28556.45.camel@localhost.localdomain \
    --to=oyvind.harboe@zylin.com \
    --cc=ecos-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).