z/OS MVS Programming: Resource Recovery
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Contexts

z/OS MVS Programming: Resource Recovery
SA23-1395-00

A context can be either:
  • A native context, which is the automatically occurring context of the application program and protected resources associated with a work request. A native context is associated with a single application task. This context always exists.
  • A privately-managed context, which a resource manager creates. The resource manager owns a privately-managed context it creates, and the resource manager can switch a privately-managed context from one task to another. A privately-managed context is usually used by a work manager, which is a resource manager, like IMS™, that accepts and manages work, such as transactions, from outside the system.

Table 1 summarizes the differences between the two types of contexts.

Table 1. Context Type Differences
Difference Native Context Privately-Managed Context
Creation of context Implicitly by the operating system Explicitly by a resource manager
Association of context Always with an application's task Temporarily may not be associated with any task
Association change Cannot change association from one application's task to another Can change association from one application's task to another at any time. The change can even be to a work unit in a different home address space
Context end
  • When the application's task ends
  • When a resource manager running under the application's task explicitly ends the context (though a new native context automatically begins)
  • When the home address space of the application's task abnormally ends
  • When a resource manager explicitly ends a privately-managed context that it owned. If the context is associated with an application's task, the resource manager must be running under that task
  • If the owning resource manager ends or unregisters, a context disassociated from an application's task ends immediately
  • If the owning resource manager ends or unregisters, a context associated with an application's task continues until the task ends
  • If the application's task associated with a privately-managed context ends, the system invokes the PVT_CONTEXT_OWNER exit routine, if provided. The routine indicates if the privately-managed context is to be ended or disassociated from the task
Expressing Interest in a Context: A resource manager expresses interest in a context to cause the system to invoke the resource manager's exit routine when:
  • The context ends
  • The context switches from one application's task to another
When expressing interest in a context, a resource manager can provide context interest data. This data can contain an anchor for the resource manager's data structures for the context.

When a resource manager expresses interest in a context, the system provides a context token that represents the context. The context token is unique within an MVS™ system or sysplex but is not guaranteed to be unique across a network of MVS systems.

Privately-Managed Contexts: When a resource manager that is processing transactions creates a new work request, the resource manager should create a new privately-managed context for the request. The resource manager can associate the context with the application's task that will run for the work request.

If needed, the resource manager can disassociate the privately-managed context from a task and later reassociate it with the same task or another task. By changing the associations, the resource manager can have one task that runs for many work requests, many tasks that run in series for a single work request, or both. Note that a context cannot be associated at the same time with multiple tasks.

When a task changes from processing for one work request to processing for another work request, the resource manager should switch the privately-managed contexts associated with the task.

Current Context: Every task in the system has an associated context; thus, there is always a context for a given task. When a task is created, context services provides the original (native) context for the task. A call to the Begin_Context service creates a privately-managed context, and a call to the Switch_Context service changes the current context to the privately-managed context. The native context still exists, but is not current. If a later call to the Switch_Context service disassociates the privately-managed context, the native context again becomes the current context.

If a privately-managed context associated with a task ends, the native context becomes the current context. If a task ends while there is a privately-managed context associated with it, the privately-managed context ends, followed immediately by the end of the task's native context.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014