6.4.2 Getting a Message Priority
The tpsprio(3c) function enables you to get the priority of a message request.
Use the following signature to call the tpgprio()
function:
int
tpgprio();
A requester can call the tpgprio()
function after invoking the tpcall()
or tpacall() function to retrieve the priority of the request message. If a requester calls the function but no request is sent, the function fails, returning -1
and setting tperrno(5) to TPENOENT
. Upon success, tpgprio()
returns an integer value in the range of 1 to 100 (where the highest priority value is 100).
If a priority has not been explicitly set using the tpsprio() function, the system sets the message priority to that of the service routine that handles the request. Within an application, the priority of the request-handling service is assigned a default value of 50 unless a system administrator overrides this value.
The following example shows how to determine the priority of a message that was sent in an asynchronous call.
Listing Determining the Priority of a Request After It Is Sent
#include <stdio.h>
#include "atmi.h"
main ()
{
int cd1, cd2; /* call descriptors */
int pr1, pr2; /* priorities to two calls */
char *buf1, *buf2; /* buffers */
long buf1len, buf2len; /* buffer lengths */
join application
if (buf1=tpalloc("FML", NULL, 0) == NULL)
error
if (buf2=tpalloc("FML", NULL, 0) == NULL)
error
populate FML buffers with send request
if ((cd1 = tpacall("service1", buf1, 0, 0)) == -1)
error
if ((pr1 = tpgprio()) == -1)
error
if ((cd2 = tpacall("service2", buf2, 0, 0)) == -1)
error
if ((pr2 = tpgprio()) == -1)\
error
if (pr1 >= pr2) { /* base the order of tpgetrplys on priority of calls */
if (tpgetrply(&cd1, &buf1, &buf1len, 0) == -1)
error
if (tpgetrply(&cd2, &buf2, &buf2len, 0) == -1)
error
}
else {
if (tpgetrply(&cd2, &buf2, &buf2len, 0) == -1)
error
if (tpgetrply(&cd1, &buf1, &buf1len, 0) == -1)
error
}
. . .
}
Parent topic: Setting and Getting Message Priorities