Article View: comp.std.c++
Article #2155Threads and Exceptions
From: 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. ]
Technical Details
Message-ID:
<rbarrisDG7L96.F9q@netcom.com>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: rbarris@netcom.com (Robert Barris) Newsgroups: comp.std.c++ Subject: Threads and Exceptions Date: 10 Oct 1995 02:25:40 GMT Organization: NETCOM On-line Communication Services (408 261-4700 guest) Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <rbarrisDG7L96.F9q@netcom.com> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text Apparently-To: comp-std-c++@uunet.uu.net Content-Length: 1564 Originator: clamage@taumet