Resource group allocation rules
Resource group allocation rules are used to decide which resources from a resource group will be allocated when allocation to a load is performed. They are also used for reallocation if reallocation has been enabled for the group.
You can create a custom resource group allocation rule and its corresponding function. The function can have any name that is not a standard system function name. It must accept four arguments in the following order:
- A pointer to the resource group, Type: RESGRP *.
- An integer for the number of resources to be selected from that group for allocation, Type: int.
- A pointer to the load requesting to allocate from the resource group, Type: LOAD*.
- A list to be populated with RMTAGS (group) of resources selected for allocation from the group, Type: CSLIST*.
Group members can be added and removed from the list of selected resources (mlist) using the system support functions seadsl and sermsl, respectively. To add group members to the list, use function seadsl as follows:
void seadsl(CSLIST *mlist, RESMEMB *rmp)
To remove group members from the list, use function sermsl as follows:
void sermsl(CSLIST *mlist, RMTAG *rmt)
Your custom function should return nothing (Type: void). Here is an example of a rule to select available resource group members on the basis of least mean utilization:
void rgsr (RESGRP *gp, int nu, LOAD *ldp, CSLIST *mlist)
/*-----------------------------------------------------------------
Function to process resource group selection code 3, select
required number of member resources that have the least mean
utilizations (as a fraction of capacity).
NOTES:
* Ties are broken by selecting the first in the order listed in the
group.
* This function requires that resource statistics be enabled.
Any resource which does not have statistics enabled is
assumed to have a utilization of zero. Thus if all
resource statistics are disabled, this degenerates to
rule 0.
* This function uses seaars, which includes must complete and
maxOT in its considerations, to determine the availability
of each member resource.
ARGS:
gp - pointer to resource group to select member from
nu - number of units required from selected member
ldp - pointer to load to which resource will be allocated
mlist - list to hold selected RESMEMB's
RETURNS: void
-----------------------------------------------------------------*/
{
int i, j, *avail;
double min, *util;
RESMEMB *minp, *rmp;
/* Allocate arrays for availability and utilization. */
avail = (int *) malloc(sizeof(int) * csszls(gp->rgrsls));
if ( avail == NULL )
{
seferr(0, "Out of Memory");
}
util = (double *) malloc(sizeof(double) * csszls(gp->rgrsls));
if ( util == NULL )
{
seferr(0, "Out of Memory");
}
/* Compute availability and utilization. */
for ( rmp = (RESMEMB *) csfsls(gp->rgrsls), j = 0;
rmp != NULL;
rmp = (RESMEMB *) csnxls((CSENTITY *) rmp), j++ )
{
avail[j] = seaars(rmp->rmres, ldp);
util[j] = seutrs(rmp->rmres);
}
/* For the required number of units */
for ( i = csszls(mlist); i < nu; i++ )
{
/* For each resource which is available. */
minp = NULL;
for ( rmp = (RESMEMB *) csfsls(gp->rgrsls), j = 0;
rmp != NULL;
rmp = (RESMEMB *) csnxls((CSENTITY *) rmp), j++ )
{
if ( (! rmp->rmres->rsselfg) && (avail[j] > 0) )
{
/* Save if min. */
if ( (minp == NULL) || (util[j] < min) )
{
minp = rmp;
min = util[j];
}
}
}
if ( minp == NULL )
{
break;
}
seadsl(mlist, minp);
}
free(avail);
free(util);
return;
}
To make your tailored resource group allocation function available to the Scheduler, you must “install” it from the first user-initialization function ucini1 by calling the function sedfgs. The function sedfgs has two arguments in the following order:
- The number of the resource group allocation rule for which your function contains tailored logic.
- The address of your resource group allocation function.