f



C++ Exception handling in Tornado2.2

Hi,
        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 ?...
        (I know that some versions of gcc's exception handling feature
does not work properly in multithreaded environment)
        Has anybody tried this before? ANY HELP??
     
Regards
Pavan

0
2/2/2006 3:25:02 AM
comp.os.vxworks 5962 articles. 4 followers. motamedi24 (67) is leader. Post Follow

2 Replies
529 Views

Similar Articles

[PageSpeed] 53

pavana.murthy@gmail.com wrote:
> Hi,
>         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 ?...

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.

>         (I know that some versions of gcc's exception handling feature
> does not work properly in multithreaded environment)
Exceptions have worked in Wind's C++ distributions since Tornado 2.0,
by my experience.

>         Has anybody tried this before? ANY HELP??
>      
> Regards
> Pavan
> 
0
bill4529 (104)
2/2/2006 2:51:54 PM
> pavana.murthy@gmail.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, bill@qswtools.com 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.

fwiw,
Bill Pringlemeir.

-- 
The goal of science is to inspire the mind.

vxWorks FAQ, "http://www.xs4all.nl/~borkhuis/vxworks/vxworks.html"
0
spam_account (239)
2/2/2006 3:13:25 PM
Reply: