Definitions Model and Definitions
on behalf of the same transaction, from different branches. The different branches are
related in that they must be completed atomically.
Each transaction branch identifier (or XID — see Section 4.2 on page 19) that the TM
gives the RM identifies both a global transaction and a specific branch. The RM may
use this information to optimise its use of shared resources and locks.
2.2.7 Transaction Manager
TMs manage global transactions, coordinate the decision to commit them or roll them
back, and coordinate failure recovery. The AP defines the start and end of a global
transaction by calling a TM. The TM assigns an identifier to the global transaction (see
Section 4.2 on page 19). The TM manages global transactions and informs each RM of
the XID on behalf of which the RM is doing work. Although RMs can manage their
own recoverable work units as they see fit, each RM must accept XIDs and associate
them with those work units. In this way, an RM knows what recoverable work units to
complete when the TM completes a global transaction.
2.2.8 Thread of Control
A thread of control (or a thread) is the entity, with all its context, that is currently in
control of a processor. A thread of control is an operating-system process: an address
space and single thread of control that executes within that address space, and its
required system resources. The context may include the process’ locks on shared
resources, and the files the process has open. For portability reasons, the notion of
thread of control must be common among the AP, TM and RM.
The thread concept is central to the TM’s coordination of RMs. APs call RMs to request
work, while TMs call RMs to delineate transaction branches. The way the RM knows
that a given work request pertains to a given branch is that the AP and the TM both call
it from the same thread of control. For example, an AP thread calls the TM to declare the
start of a global transaction. The TM records this fact and informs RMs. After the AP
regains control, it uses the native interface of one or more RMs to do work. The RM
receives the calls from the AP and TM in the same thread of control.
Certain XA routines, therefore, must be called from a particular thread. The reference
manual pages in Chapter 5 indicate which routines require this.
2.2.9 Tightly- and Loosely-coupled Threads
Many application threads of control can participate in a single global transaction. All
the work done in these threads is atomically completed. Within a single global
transaction, the relationship between any pair of participating threads is either tightly-
coupled or loosely-coupled:
• A tightly-coupled relationship is one where a pair of threads are designed to share
resources. In addition, with respect to an RM’s isolation policies, the pair are
treated as a single entity. Thus, for a pair of tightly-coupled threads, the RM must
guarantee that resource deadlock does not occur within the transaction branch.
6
X/Open CAE Specification (1991)