Providing recovery

In an ideal world, the programs you write would run perfectly, and never encounter an error, either software or hardware. In the real world, programs do encounter errors that can result in the premature end of the program's processing. These errors could be caused by something your program does, or they could be beyond your program's control.

MVS™ allows you to provide something called recovery for your programs; that means you can anticipate and possibly recover from software errors that could prematurely end a program. To recover from these errors, you must have one or more user-written routines called recovery routines. The general idea is that, when something goes wrong, you have a recovery routine standing by to take over, fix the problem, and return control to your program so that processing can complete normally; if the problem cannot be fixed, the recovery routine would provide information about what went wrong. If correctly set up, your recovery should, at the very least, provide you with more information about what went wrong with your program than you would have had otherwise.

Part of recovery is also the "cleaning up" of any resources your program might have acquired. By "clean up" of resources, we mean that programs might need to release storage that was obtained, release ENQs, close data sets, and so on. If your program encounters an error before it has the opportunity to clean up resources, either your recovery routine, or another type of user-written routine called a resource manager, can do the clean up. You can also use a resource manager if your program ends normally without encountering any errors.

MVS provides the recovery termination manager (RTM) to handle the process by which recovery routines and resource managers receive control.

Most of this information is devoted to explaining why you might want to provide recovery for your programs in anticipation of encountering one or more errors, and how you go about doing that. An important point to note is that providing recovery is something to be considered at the design stage of your program. You should make the decision about whether to provide recovery before you begin designing the program. Trying to provide recovery for an existing program is much more difficult because recovery must be an integral part of your program.

This information also discusses why you might want to provide resource managers to clean up resources acquired by your program, and how you go about doing that. You can provide resource managers whether or not you provide recovery routines. See Using resource managers for further information.

The following table provides a roadmap to the information in this topic. If you already understand recovery concepts, you might want to skip directly to those topics of specific interest to you.

To find out about: Consult the following topic:
General recovery concepts, including:
  • Why you would want to provide recovery.
  • What software errors result in your recovery getting control.
  • What we mean when we say a program abnormally ends.
  • The different states for a recovery routine.
  • The different types of routines in a recovery environment, and how to choose, define, and activate the right recovery routine.
  • The basic options available to a recovery routine.
  • How routines in a recovery environment interact.
Understanding general recovery concepts.
How to write a recovery routine, including:
  • What recovery routines do.
  • How recovery routines communicate with other routines and with the system.
  • Special considerations when writing different types of recovery routines.
Writing recovery routines.
The recovery environment, including:
  • Register contents at various times during recovery processing.
  • Other environmental factors such as program authorization, dispatchable unit mode, ASC mode, and so on.
Understanding the recovery environment.
Coding the various routines in a typical recovery environment. Understanding recovery through a coded example.
Advanced recovery topics, including:
  • Providing recovery with minimal processor overhead (for types 2, 3, and 4 SVCs only).
  • Intentionally invoking RTM.
  • Providing multiple recovery routines.
  • Providing recovery for recovery routines.
  • Providing recovery for multitasking programs
  • Using resource managers.
Understanding advanced recovery topics.