public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Lightweight C++ multithreaded exceptions
@ 2005-05-23  9:13 Øyvind Harboe
  2005-05-23 12:52 ` Jerome Souquieres
  0 siblings, 1 reply; 6+ messages in thread
From: Øyvind Harboe @ 2005-05-23  9:13 UTC (permalink / raw)
  To: ecos-discuss

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-05-23 19:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-23  9:13 [ECOS] Lightweight C++ multithreaded exceptions Øyvind Harboe
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

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).