Thread View: comp.std.c++
4 messages
4 total messages
Started by Robert Barris
Tue, 10 Oct 1995 02:25
Threads and Exceptions
Author: Robert Barris
Date: Tue, 10 Oct 1995 02:25
Date: Tue, 10 Oct 1995 02:25
38 lines
2313 bytes
2313 bytes
I have a question about threads and C++ exceptions. Is it expected that a C++ compiler environment should provide a mechanism for ensuring that exception handling can be done safely in a multi-threaded program? As I understand exception handling, a fair bit of runtime state munging must take place (unwinding the stack and so forth) when exceptions are thrown and caught, and in order to implement this there is usually some global state being kept about the calling chain and objects which must be "destructed" when an exception does arise. One of the compilers I am using (Metrowerks CodeWarrior) provides some functions for getting and setting the state variables associated with each thread, and their thread class makes use of that feature to provide for correct exception handling even in multiple threads. [ These are "co-operative threads" and as such have explicit yield points in them, presumably any pre-emptive implementation would need a way to get control at the time of the thread context switch - or would duck the problem by implementing exception handling without static globals, using thread local storage instead for each thread's state info ] What I am wondering is: are these part of the standard or is something like them expected to become part of the standard? And to be more concrete, can anyone explain Borland, Watcom, Microsoft compilers' approach to this issue (if any?) [bimby helmet on] Rob Barris Quicksilver Software Inc. rbarris@quicksilver.com * Opinions expressed not necessarily those of my employer * [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: Threads and Exceptions
Author: Steve Clamage
Date: Tue, 10 Oct 1995 15:02
Date: Tue, 10 Oct 1995 15:02
37 lines
1963 bytes
1963 bytes
rbarris@netcom.com (Robert Barris) writes: >I have a question about threads and C++ exceptions. >Is it expected that a C++ compiler environment should provide a mechanism for >ensuring that exception handling can be done safely in a multi-threaded >program? Threads or other forms of multi-tasking are not addressed in the C++ draft standard, and are not likely to be. >... >One of the compilers I am using (Metrowerks CodeWarrior) provides some >functions for getting and setting the state variables associated with >each thread, and their thread class makes use of that feature to provide >for correct exception handling even in multiple threads. > ... >What I am wondering is: are these part of the standard or is something >like them expected to become part of the standard? No. You should expect exceptions to work correctly in a C++ implementation. But if an implementation provided a multi-tasking capability and documented that, for example, you had to disable exceptions in order to use it, I don't believe that would violate any provision of the standard. -- Steve Clamage, stephen.clamage@eng.sun.com [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: Threads and Exceptions
Author: Mike Stump
Date: Wed, 11 Oct 1995 05:47
Date: Wed, 11 Oct 1995 05:47
19 lines
1249 bytes
1249 bytes
In article <rbarrisDG7L96.F9q@netcom.com>, Robert Barris <rbarris@netcom.com> wrote: >Is it expected that a C++ compiler environment should provide a mechanism for >ensuring that exception handling can be done safely in a multi-threaded >program? Sure. In time. >What I am wondering is: are these part of the standard Threads are not part of the C++ draft Standard. >or is something like them expected to become part of the standard? No form of threads will make it into the first ANSI/ISO C++ Standard. --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: Threads and Exceptions
Author: db
Date: Fri, 13 Oct 1995 02:05
Date: Fri, 13 Oct 1995 02:05
28 lines
1781 bytes
1781 bytes
rbarris@netcom.com (Robert Barris) wrote:
>I have a question about threads and C++ exceptions.
>
>Is it expected that a C++ compiler environment should provide a mechanism for
>ensuring that exception handling can be done safely in a multi-threaded
>program?
I'm not alone in _expecting_ that out of a reasonable compiler! And
in fact, it's known to be possible. I work with compilers every day
which do that.
However, it's true that this is a bit beyond scope of the current C++
standards work ... just as for example the POSIX threading standard does
not address a C++ binding for POSIX Threads.
Some questions to think about: when threads are canceled, how do they
clean up? What's the interaction of C and C++ cleanup mechanisms? And
what good would the POSIX "asynchronous cancellation" mode be to a C++
program?
--
David Brownell db@Eng.Sun.COM.
Enterprise Distributed Objects
main(a){printf(a,34,a="main(a){printf(a,34,a=%c%s%c,34);}",34);}
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads