Browse Prior Art Database

Method to Enable TRY/CATCH Support in Main Thread Under OS/2 Distributed Computing Environment Threads

IP.com Disclosure Number: IPCOM000114626D
Original Publication Date: 1995-Jan-01
Included in the Prior Art Database: 2005-Mar-29
Document File: 4 page(s) / 138K

Publishing Venue

IBM

Related People

Hidalgo, DS: AUTHOR [+3]

Abstract

Disclosed is an invention which provides the means for OS/2* Distributed Computing Environment** (DCE) threads to support TRY/CATCH clauses for exception and error handling in the main program thread.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 43% of the total text.

Method to Enable TRY/CATCH Support in Main Thread Under OS/2 Distributed
Computing Environment Threads

      Disclosed is an invention which provides the means for OS/2*
Distributed Computing Environment** (DCE) threads to support
TRY/CATCH clauses for exception and error handling in the main
program thread.

      The TRY/CATCH method of exception and error handling has become
more common in recent years thanks to the Portable Operating System
Interface (POSIX) thread interface standard and to some object
oriented environments.  Under OS/2 DCE threads the support for
TRY/CATCH is based on the use of an exception handler per thread.
While all child threads have this handler installed when they are
created with the standard pthread_create() function, the main thread
presents a problem as this thread is created by OS/2 and no means
exists in the OS/2 DCE threads to install an exception handler before
the first TRY/CATCH in the main thread is executed.

      Support of TRY/CATCH style of exception and error handling is a
must in any POSIX threads implementation.  Under the OS/2 DCE threads
package the support for this feature is based upon the use of the
setjmp()/longjmp() functions, and upon the use of the OS/2 exception
handling scheme.  Under this scheme, each OS/2 thread may have one or
more exception handlers installed at any given time.  OS/2 DCE
threads install its own exception handler when pthread_create() is
called, which makes it possible to support the CATCH clauses in that
thread by having the exception handler perform a longjmp() call to
the context saved by the setjmp() that is part of the TRY macro.
Since the main thread in OS/2 programs isn't started by pthreads,
CATCH clauses in that thread won't work unless OS/2 DCE pthreads
extends its interface to include a method to install an OS/2
exception handler in the main thread.  Furthermore, this method must
deal with the OS/2 requirement that the exception handler be
installed using a registration record that is declared as a local
variable in the function making the OS/2 DosSetExceptionHandler()
system call, and consequentially, only that function may call
DosUnsetExceptionHandler() to remove the handler at program
termination time.

      This invention provides the means for OS/2 DCE threads to
support TRY/CATCH clauses in the main program thread by making
possible the installation and removal of the OS/2 DCE threads
exception handler in that thread.  This means consists of the new
function pthread_inst_exception_handler(), which must be called as
the first executable statement in the main() function, and the pseudo
function pthread_dinst_exception_handler(), which must be called as
the last executable statement before any return statement from the
main() function.

      The pthread_inst_exception_handler() function and the
pthread_dinst_exception_handler() function are actually pseudo
functions because calls to them are expanded by macros into a ser...