> email@example.com wrote:
>> I am working on an application with uses c++ compiler provided by
>> Tornado ( Gcc version 2.96). The application uses c++ exception
>> handling features. Now, Is it safe to use c++ exception handling
>> features int a multithreaded enovironmmnet ?...
On 2 Feb 2006, firstname.lastname@example.org wrote:
> It's safe. Exceptions are caught only in the the thread that threw
> them. What you need to be careful about is avoiding exception- or
> RTTi-enabled code at interrupt level.
The other caveat is not to share object instances between tasks
(threads in other OSs). This will work, but it is highly prone to
race conditions. A lot of people will start out with C++ and threads
to do this only to later find they need mutexes everywhere.
Use the standard vxWorks IPC mechanisms and not object data to
communicate between tasks. On the question of exceptions, an object
created in one thread that is deleted by an exception will provide no
notification to the other thread that it has been deleted. Not good!
There is a significant code space overhead for exceptions and rtti.
This overhead is applied no matter if you use the feature or not. It
can be up to 10% extra code size in my experience. However, if you
are compiling with exceptions enabled, you should probably use it.
The goal of science is to inspire the mind.
vxWorks FAQ, "http://www.xs4all.nl/~borkhuis/vxworks/vxworks.html"