6.4.1 Setting a Message Priority

The tpsprio(3c) function enables you to set the priority of a message request.

The tpsprio() function affects the priority level of only one request: the next request to be sent by tpcall() or tpacall(), or to be forwarded by a service subroutine.

Use the following signature to call the tpsprio() function:

int
tpsprio(int prio, long flags);

The following table describes the arguments to the tpsprio() function.

Table 6-3 tpsprio( ) Function Arguments

Argument Description
prio Integer indicating a new priority value. The effect of this argument is controlled by the flags parameter. If flags is set to 0, prio specifies a relative value and the sign accompanying the value indicates whether the current priority is incremented or decremented. Otherwise, the value specified indicates an absolute value and prio must be set to a value between 0 and 100. If you do not specify a value within this range, the system sets the value to 50.
flags Flag indicating whether the value of prio is treated as a relative value (0, the default) or an absolute value (TPABSOLUTE).

The following sample code is an excerpt from the TRANSFER service. In this example, the TRANSFER service acts as a client by sending a synchronous request, via tpcall(), to the WITHDRAWAL service. TRANSFER also invokes tpsprio() to increase the priority of its request message to WITHDRAWAL, and to prevent the request from being queued for the WITHDRAWAL service (and later the DEPOSIT service) after waiting on the TRANSFER queue.

Listing Setting the Priority of a Request Message

/* increase the priority of withdraw call */
if (tpsprio(PRIORITY, 0L) == -1)
   (void)userlog("Unable to increase priority of withdraw\n");

if (tpcall("WITHDRAWAL", (char *)reqfb,0, (char **)&reqfb, (long *)
\
         &reqlen,TPSIGRSTRT) == -1) {
      (void)Fchg(transf, STATLIN, 0, "Cannot withdraw from debit account", \
          (FLDLEN)0);
      tpfree((char *)reqfb);
      tpreturn(TPFAIL, 0,transb->data, 0L, 0);
}